Skip to content
Snippets Groups Projects
Commit cc37808b authored by Max Kahnt's avatar Max Kahnt
Browse files

Cleanup types, namespace and documentation.

parent 762c8d4e
No related branches found
No related tags found
No related merge requests found
...@@ -7,27 +7,27 @@ ...@@ -7,27 +7,27 @@
#include <dune/common/hybridutilities.hh> #include <dune/common/hybridutilities.hh>
#include <dune/common/typetraits.hh> #include <dune/common/typetraits.hh>
#include <dune/common/std/type_traits.hh>
namespace Dune { namespace Dune {
namespace MatrixVector { namespace MatrixVector {
/** template<class T>
* \brief Hybrid for loop over sparse range constexpr auto isTupleOrDerived() {
*/ return Std::bool_constant<IsTupleOrDerived<std::decay_t<T>>::value>();
template <class Range, class F, }
std::enable_if_t<Dune::IsTupleOrDerived<std::decay_t<Range>>::value, int> = 0>
//! \brief Hybrid for loop over sparse range (static/tuple-like candidate)
template <class Range, class F, std::enable_if_t<isTupleOrDerived<Range>(), int> = 0>
void sparseRangeFor(Range&& range, F&& f) { void sparseRangeFor(Range&& range, F&& f) {
using namespace Dune::Hybrid; using namespace Dune::Hybrid;
forEach(integralRange(Dune::Hybrid::size(range)), [&](auto&& i) { forEach(integralRange(size(range)), [&](auto&& i) {
f(range[i], i); f(range[i], i);
}); });
} }
/** //! \brief Hybrid for loop over sparse range (dynamic/sparse candidate)
* \brief Hybrid for loop over sparse range template<class Range, class F, std::enable_if_t<not isTupleOrDerived<Range>(), int> = 0>
*/
template<class Range, class F,
std::enable_if_t<not Dune::IsTupleOrDerived<std::decay_t<Range>>::value, int> = 0>
void sparseRangeFor(Range&& range, F&& f) void sparseRangeFor(Range&& range, F&& f)
{ {
auto it = range.begin(); auto it = range.begin();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment