Hybrid Utilities
[Utilities]

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 >
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.

Detailed Description

Hybrid utility functions that work on homogeneous as well as heterogeneous containers.


Function Documentation

template<class Range , class T , class F >
T Dune::Hybrid::accumulate ( Range &&  range,
value,
F &&  f 
) [inline]

Accumulate values.

Template Parameters:
Range Type of given range
T Type of accumulated value
F Type of binary accumulation operator
Parameters:
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

template<class Condition , class IfFunc , class ElseFunc >
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.

template<class Container , class Index >
constexpr Dune::Hybrid::decltype ( auto   )  [inline]

Get element at given position from container.

Template Parameters:
Container Type of given container
Index Type of index
Parameters:
c Given container
i Index of element to obtain
Returns:
The element at position i, i.e. c[i]

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

template<class T1 , class T2 >
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.

template<class Range , class F >
constexpr void Dune::Hybrid::forEach ( Range &&  range,
F &&  f 
) [inline]

Range based for loop.

Template Parameters:
Range Type of given range
F Type of given predicate
Parameters:
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.

template<class End >
constexpr auto Dune::Hybrid::integralRange ( const End &  end  )  [inline]

Create an integral range starting from 0.

Template Parameters:
End Type of end entry of the range
Parameters:
end One past the last entry of the range
Returns:
An object encoding the given range

This is a short cut for integralRange(_0, end).

template<class T >
constexpr auto Dune::Hybrid::size ( const T &  t  )  [inline]

Size query.

Template Parameters:
T Type of container whose size is queried
Parameters:
t Container whose size is queried
Returns:
Size of t

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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 25 Mar 2018 for dune-common by  doxygen 1.6.1