Dune Core Modules (unstable)

Utilities for indices, index constants, and multi-indices. More...

Namespaces

namespace  Dune::Indices
 Namespace with predefined compile time indices for the range [0,19].
 

Classes

class  Dune::HybridMultiIndex< T >
 A hybrid multi-index class that supports both compile time and run time indices. More...
 

Typedefs

template<std::size_t i>
using Dune::index_constant = std::integral_constant< std::size_t, i >
 An index constant with value i. More...
 

Functions

template<class F , class I , I... i>
decltype(auto) constexpr Dune::unpackIntegerSequence (F &&f, std::integer_sequence< I, i... > sequence)
 Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>... More...
 
template<typename... T>
constexpr auto back (const HybridMultiIndex< T... > &tp) -> decltype(tp.back())
 Returns a copy of the last element of the HybridMultiIndex. More...
 
template<typename... T>
constexpr auto front (const HybridMultiIndex< T... > &tp) -> decltype(tp.front())
 Returns a copy of the first element of the HybridMultiIndex. More...
 
template<typename... T>
constexpr HybridMultiIndex< T..., std::size_t > push_back (const HybridMultiIndex< T... > &tp, std::size_t i)
 Appends a run time index to a HybridMultiIndex. More...
 
template<std::size_t i, typename... T>
constexpr HybridMultiIndex< T..., index_constant< i > > push_back (const HybridMultiIndex< T... > &tp, index_constant< i > iConstant={})
 Appends a compile time index to a HybridMultiIndex. More...
 
template<typename... T>
constexpr HybridMultiIndex< std::size_t, T... > push_front (const HybridMultiIndex< T... > &tp, std::size_t i)
 Prepends a run time index to a HybridMultiIndex. More...
 
template<std::size_t i, typename... T>
constexpr HybridMultiIndex< index_constant< i >, T... > push_front (const HybridMultiIndex< T... > &tp, index_constant< i > iConstant={})
 Prepends a compile time index to a HybridMultiIndex. More...
 
template<typename I , typename... T>
constexpr auto accumulate_back (const HybridMultiIndex< T... > &tp, I i)
 Hybrid utility that accumulates to the back of a multi-index. More...
 
template<typename I , typename... T>
constexpr auto accumulate_front (const HybridMultiIndex< T... > &tp, I i)
 Hybrid utility that accumulates to the front of a multi-index. More...
 
template<class... Head, class... Other>
constexpr auto join (const HybridMultiIndex< Head... > &head, const Other &... tail)
 Join two hybrid multi-indices into one.
 
template<class... T>
constexpr auto reverse (const HybridMultiIndex< T... > &tp)
 Reverses the order of the elements in the multi-index.
 
template<class... T>
constexpr auto pop_front (const HybridMultiIndex< T... > &tp)
 Removes first index on a HybridMultiIndex. More...
 
template<class... T>
constexpr auto pop_back (const HybridMultiIndex< T... > &tp)
 Removes last index on a HybridMultiIndex. More...
 
template<class... S, class... T>
constexpr bool operator== (const HybridMultiIndex< S... > &lhs, const HybridMultiIndex< T... > &rhs)
 Compare two HybridMultiIndexs for value equality. More...
 
template<class S , S... lhs, class T , T... rhs>
constexpr auto operator== (const HybridMultiIndex< std::integral_constant< S, lhs >... > &, const HybridMultiIndex< std::integral_constant< T, rhs >... > &)
 Overload for purely static HybridMultiIndexs. More...
 
template<class... S, class... T>
constexpr auto operator!= (const HybridMultiIndex< S... > &lhs, const HybridMultiIndex< T... > &rhs)
 Compare two HybridMultiIndexs for inequality.
 
template<class S , S... lhs, class T , T... rhs>
constexpr auto operator!= (const HybridMultiIndex< std::integral_constant< S, lhs >... > &, const HybridMultiIndex< std::integral_constant< T, rhs >... > &)
 Compare two static HybridMultiIndexs for inequality.
 
template<typename... T>
std::ostream & operator<< (std::ostream &os, const HybridMultiIndex< T... > &tp)
 Dumps a HybridMultiIndex to a stream.
 

Detailed Description

Utilities for indices, index constants, and multi-indices.

Typedef Documentation

◆ index_constant

template<std::size_t i>
using Dune::index_constant = typedef std::integral_constant<std::size_t, i>

An index constant with value i.

An index constant is a simple type alias for an integral_constant. Its main advantages are clarity (it is easier to see that code uses it as an index) and the fact that the integral type is fixed, reducing verbosity and avoiding the problem of maybe trying to overload / specialize using a different integral type.

Function Documentation

◆ accumulate_back()

template<typename I , typename... T>
constexpr auto accumulate_back ( const HybridMultiIndex< T... > &  tp,
i 
)
related

Hybrid utility that accumulates to the back of a multi-index.

The back of the multi-index will be accumulated and promoted in order to hold the new index:

A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:85
constexpr auto accumulate_back(const HybridMultiIndex< T... > &tp, I i)
Hybrid utility that accumulates to the back of a multi-index.
Definition: hybridmultiindex.hh:323

References Dune::back(), Dune::Hybrid::plus, and Dune::push_back().

◆ accumulate_front()

template<typename I , typename... T>
constexpr auto accumulate_front ( const HybridMultiIndex< T... > &  tp,
i 
)
related

Hybrid utility that accumulates to the front of a multi-index.

The front of the multi-index will be accumulated and promoted in order to hold the new index:

constexpr auto accumulate_front(const HybridMultiIndex< T... > &tp, I i)
Hybrid utility that accumulates to the front of a multi-index.
Definition: hybridmultiindex.hh:345

References Dune::front(), Dune::Hybrid::plus, and Dune::push_front().

◆ back()

template<typename... T>
constexpr auto back ( const HybridMultiIndex< T... > &  tp) -> decltype(tp.back())
related

Returns a copy of the last element of the HybridMultiIndex.

As HybridMultiIndex instances should not be mutated after their creation, this function returns a copy of the value. As values are either std::integral_constant or std::size_t, that's just as cheap as returning a reference.

◆ front()

template<typename... T>
constexpr auto front ( const HybridMultiIndex< T... > &  tp) -> decltype(tp.front())
related

Returns a copy of the first element of the HybridMultiIndex.

As HybridMultiIndex instances should not be mutated after their creation, this function returns a copy of the value. As values are either std::integral_constant or std::size_t, that's just as cheap as returning a reference.

◆ operator==() [1/2]

template<class... S, class... T>
constexpr bool operator== ( const HybridMultiIndex< S... > &  lhs,
const HybridMultiIndex< T... > &  rhs 
)
related

Compare two HybridMultiIndexs for value equality.

The function returns true if both hybrid multi-indices are of the same length and all entries have the same value.

Note, it might be that the values are represented with different types. To check for same value and same type, use a combination of std::is_same and this comparison operator.

References Dune::HybridMultiIndex< T >::enumerate(), and Dune::unpackIntegerSequence().

◆ operator==() [2/2]

template<class S , S... lhs, class T , T... rhs>
constexpr auto operator== ( const HybridMultiIndex< std::integral_constant< S, lhs >... > &  ,
const HybridMultiIndex< std::integral_constant< T, rhs >... > &   
)
related

Overload for purely static HybridMultiIndexs.

The function returns std::true_type if the values of the passed multi-indices are equal. Otherwise returns std::false_type. Note, this overload is chosen for purely static multi-indices only.

◆ pop_back()

template<class... T>
constexpr auto pop_back ( const HybridMultiIndex< T... > &  tp)
related

Removes last index on a HybridMultiIndex.

This function returns a new HybridMultiIndex without the last index.

References Dune::unpackIntegerSequence().

◆ pop_front()

template<class... T>
constexpr auto pop_front ( const HybridMultiIndex< T... > &  tp)
related

Removes first index on a HybridMultiIndex.

This function returns a new HybridMultiIndex without the first index.

References Dune::unpackIntegerSequence().

◆ push_back() [1/2]

template<std::size_t i, typename... T>
constexpr HybridMultiIndex< T..., index_constant< i > > push_back ( const HybridMultiIndex< T... > &  tp,
index_constant< i >  iConstant = {} 
)
related

Appends a compile time index to a HybridMultiIndex.

This function returns a new HybridMultiIndex with the compile time index i appended.

The value for the new entry can be passed either as a template parameter or as an index_constant:

auto tp = HybridMultiIndex(1,2,3,4);
using namespace Dune::Indices;
// the following two lines are equivalent
auto tp_a = push_back<1>(tp);
auto tp_b = push_back(tp,_1);
constexpr HybridMultiIndex< T..., std::size_t > push_back(const HybridMultiIndex< T... > &tp, std::size_t i)
Appends a run time index to a HybridMultiIndex.
Definition: hybridmultiindex.hh:238
Namespace with predefined compile time indices for the range [0,19].
Definition: indices.hh:50

◆ push_back() [2/2]

template<typename... T>
constexpr HybridMultiIndex< T..., std::size_t > push_back ( const HybridMultiIndex< T... > &  tp,
std::size_t  i 
)
related

Appends a run time index to a HybridMultiIndex.

This function returns a new HybridMultiIndex with the run time index i appended.

References Dune::HybridMultiIndex< T >::enumerate(), and Dune::unpackIntegerSequence().

◆ push_front() [1/2]

template<std::size_t i, typename... T>
constexpr HybridMultiIndex< index_constant< i >, T... > push_front ( const HybridMultiIndex< T... > &  tp,
index_constant< i >  iConstant = {} 
)
related

Prepends a compile time index to a HybridMultiIndex.

This function returns a new HybridMultiIndex with the compile time index i prepended.

The value for the new entry can be passed either as a template parameter or as an index_constant:

auto tp = HybridMultiIndex(1,2,3,4);
using namespace Dune::Indices;
// the following two lines are equivalent
auto tp_a = push_front<1>(tp);
auto tp_b = push_front(tp,_1);
constexpr HybridMultiIndex< std::size_t, T... > push_front(const HybridMultiIndex< T... > &tp, std::size_t i)
Prepends a run time index to a HybridMultiIndex.
Definition: hybridmultiindex.hh:276

◆ push_front() [2/2]

template<typename... T>
constexpr HybridMultiIndex< std::size_t, T... > push_front ( const HybridMultiIndex< T... > &  tp,
std::size_t  i 
)
related

Prepends a run time index to a HybridMultiIndex.

This function returns a new HybridMultiIndex with the run time index i prepended.

References Dune::HybridMultiIndex< T >::enumerate(), and Dune::unpackIntegerSequence().

◆ unpackIntegerSequence()

template<class F , class I , I... i>
decltype(auto) constexpr Dune::unpackIntegerSequence ( F &&  f,
std::integer_sequence< I, i... >  sequence 
)
constexpr

Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...

This forward all entries of the given std::integer_sequence as individual std::integral_constant arguments to the given callback.

Parameters
fCallback which has to accept unpacked values
sequencePacked std::integer_sequence of values
Returns
Result of calling f with unpacked integers.

Referenced by Dune::filledArray(), Dune::TypeTree::forEachChild(), Dune::Std::layout_stride::mapping< Extents >::operator()(), Dune::HybridMultiIndex< T >::operator==(), Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >::operator[](), Dune::Std::mdspan< Element, Extents, LayoutPolicy, AccessorPolicy >::operator[](), Dune::HybridMultiIndex< T >::pop_back(), Dune::HybridMultiIndex< T >::pop_front(), Dune::HybridMultiIndex< T >::push_back(), Dune::HybridMultiIndex< T >::push_front(), Dune::HybridMultiIndex< T >::reverse(), and Dune::sorted().

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jun 2, 23:00, 2026)