Hybrid utility functions that work on homogeneous as well as heterogeneous containers. More...
Functions | |
template<class T > | |
constexpr auto | Dune::Hybrid::size (const T &t) |
Size query. | |
template<class Container , class Index > | |
constexpr | Dune::Hybrid::decltype (auto) elementAt(Container &&c |
Get element at given position from container. | |
template<class End > | |
constexpr auto | Dune::Hybrid::integralRange (const End &end) |
Create an integral range starting from 0. | |
template<class Range , class F > | |
constexpr void | Dune::Hybrid::forEach (Range &&range, F &&f) |
Range based for loop. | |
template<class Range , class T , class F > | |
T | Dune::Hybrid::accumulate (Range &&range, T value, F &&f) |
Accumulate values. | |
template<class Condition , class IfFunc , class ElseFunc > | |
Dune::Hybrid::decltype (auto) ifElse(const Condition &condition | |
A conditional expression. | |
template<class T1 , class T2 > | |
constexpr auto | Dune::Hybrid::equals (T1 &&t1, T2 &&t2) |
Equality comparison. |
Hybrid utility functions that work on homogeneous as well as heterogeneous containers.
T Dune::Hybrid::accumulate | ( | Range && | range, | |
T | value, | |||
F && | f | |||
) | [inline] |
Accumulate values.
Range | Type of given range | |
T | Type of accumulated value | |
F | Type of binary accumulation operator |
range | The range of values to accumulate | |
value | Initial value for accumulation | |
f | Binary operator for accumulation |
This supports looping over the same ranges as Hybrid::forEach
Dune::Hybrid::decltype | ( | auto | ) | const [inline] |
A conditional expression.
This will call either ifFunc or elseFunc depending on the condition. In any case a single argument will be passed to the called function. This will always be the indentity function. Passing an expression through this function will lead to lazy evaluation. This way both 'branches' can contain expressions that are only valid within this branch if the condition is a std::integral_constant<bool,*>.
In order to do this, the passed functors must have a single argument of type auto.
Due to the lazy evaluation mechanism and support for std::integral_constant<bool,*> this allows to emulate a static if statement.
constexpr Dune::Hybrid::decltype | ( | auto | ) | [inline] |
Get element at given position from container.
Container | Type of given container | |
Index | Type of index |
c | Given container | |
i | Index of element to obtain |
If this returns the i-th entry of c. It supports the following containers * Containers providing dynamic access via operator[] * Heterogenous containers providing access via operator[](integral_constant<...>) * std::tuple<...> * std::integer_sequence
constexpr auto Dune::Hybrid::equals | ( | T1 && | t1, | |
T2 && | t2 | |||
) | [inline] |
Equality comparison.
If both types have a static member value, the result of comparing these is returned as std::integral_constant<bool, *>. Otherwise the result of a runtime comparison of t1 and t2 is directly returned.
constexpr void Dune::Hybrid::forEach | ( | Range && | range, | |
F && | f | |||
) | [inline] |
Range based for loop.
Range | Type of given range | |
F | Type of given predicate |
range | The range to loop over | |
f | A predicate that will be called with each entry of the range |
This supports looping over the following ranges * ranges obtained from integralRange() * all ranges that provide Hybrid::size() and Hybrid::elementAt()
This especially included instances of std::integer_sequence, std::tuple, Dune::TupleVector, and Dune::MultiTypeBlockVector.
constexpr auto Dune::Hybrid::integralRange | ( | const End & | end | ) | [inline] |
Create an integral range starting from 0.
End | Type of end entry of the range |
end | One past the last entry of the range |
This is a short cut for integralRange(_0, end).
constexpr auto Dune::Hybrid::size | ( | const T & | t | ) | [inline] |
Size query.
T | Type of container whose size is queried |
t | Container whose size is queried |
If the size of t is known at compile type the size is returned as std::integral_constant<std::size_t, size>. Otherwise the result of t.size() is returned.
Supported types for deriving the size at compile time are: * instances of std::integer_sequence * all types std::tuple_size is implemented for * all typed that have a static method size() * instances of Dune::FieldVector