dune-common 2.9.1
|
Hybrid utility functions that work on homogeneous as well as heterogeneous containers. More...
Hybrid utility functions that work on homogeneous as well as heterogeneous containers.
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
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
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.
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
This especially included instances of std::integer_sequence, std::tuple, Dune::TupleVector, and Dune::MultiTypeBlockVector.
A conditional expression.
This provides an ifElse conditional with empty else clause.
decltype(auto) Dune::Hybrid::ifElse | ( | const Condition & | condition, |
IfFunc && | ifFunc, | ||
ElseFunc && | elseFunc ) |
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 identity 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.
Create an integral range.
Begin | Type of begin entry of the range |
End | Type of end entry of the range |
begin | First entry of the range |
end | One past the last entry of the range |
If Begin and End are both instances of type std::integral_constant, the returned range encodes begin and end statically.
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).
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:
|
constexpr |
Switch statement.
Cases | Type of case range |
Value | Type of value to check against the cases |
Branches | Type of branch function |
cases | A range of cases to check for |
value | The value to check against the cases |
branches | A callback that will be executed with matching entry from case list |
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.
|
constexpr |
Switch statement.
Cases | Type of case range |
Value | Type of value to check against the cases |
Branches | Type of branch function |
ElseBranch | Type of branch function |
cases | A range of cases to check for |
value | The value to check against the cases |
branches | A callback that will be executed with matching entry from case list |
elseBranch | A callback that will be executed if no other entry matches |
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.
Notice that this short circuits, e.g., if one case matches, the others are no longer evaluated.
The return value will be deduced from the else branch.