SUNphi  1.0
TupleElements.hpp File Reference

Access elements of a tuple. More...

Go to the source code of this file.

Functions

template<std::size_t I, class T >
constexpr std::tuple_element_t< I, T > && SUNphi::get (T &&t)
 
template<class Tg , class T >
constexpr Tg && SUNphi::get (T &&t)
 
template<size_t I = 0, typename T , typename F , typename = EnableIf<isTupleLike<T>>>
void SUNphi::forEach (T &&t, F &&f)
 
template<typename Tp , int... Ints>
decltype(auto) SUNphi::getIndexed (const IntSeq< Ints... > &, Tp &&tp)
 
template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getHead (Tp &&tp)
 
template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getTail (const Tp &&tp)
 
template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getAllButPos (Tp &&tp)
 
template<typename Tg , typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getAllButType (Tp &&tp)
 

Detailed Description

Access elements of a tuple.

Definition in file TupleElements.hpp.

Function Documentation

template<size_t I = 0, typename T , typename F , typename = EnableIf<isTupleLike<T>>>
void SUNphi::forEach ( T &&  t,
F &&  f 
)

Loop over all Tuple elements

Non const access to all elements of the Tuple, called recursively until I==sizeof...(Tp), incrementing the parameter I.

Template Parameters
IIndex of the Tuple element to extract
FuncFunction type
Tp...The Tuple parameters
Returns
void
Parameters
tTuple to act upon
fFunction iterating on the Tuple

Definition at line 55 of file TupleElements.hpp.

template<std::size_t I, class T >
constexpr std::tuple_element_t<I,T>&& SUNphi::get ( T &&  t)

Gets an element from the tuple.

Directly aliasing the std library. R-value case

Returns
A move-reference to the I tuple element.

Definition at line 23 of file TupleElements.hpp.

template<class Tg , class T >
constexpr Tg&& SUNphi::get ( T &&  t)

Gets the element of type T from the tuple.

Directly aliasing the std library. R-value case.

Returns
A move-reference to the T tuple type (if present).

Definition at line 34 of file TupleElements.hpp.

template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getAllButPos ( Tp &&  tp)

Returns all elements of a Tuple but the N-th one

Takes the list of component according to an index containing the first [0,N) and (N,Sizeof...(Tuple))

Example:

Tuple<int,double,char> e;
auto GetAllBut<1>(e); // Tuple<int,char>

Definition at line 125 of file TupleElements.hpp.

template<typename Tg , typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getAllButType ( Tp &&  tp)

Returns all elements of a Tuple but the type T

First search the component, then call GetAllBut with the found position as a parameter

Example:

Tuple<int,double,char> e;
auto GetAllBut<double>(e); // Tuple<int,char>

Definition at line 143 of file TupleElements.hpp.

template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getHead ( Tp &&  tp)

Gets the head of a Tuple

Return a tuple containg the first N elements of a tuple

Parameters
tpTuple from which to extract

Definition at line 86 of file TupleElements.hpp.

template<typename Tp , int... Ints>
decltype(auto) SUNphi::getIndexed ( const IntSeq< Ints... > &  ,
Tp &&  tp 
)

Filter a Tuple on the basis of a list of index

Return a tuple containg the elements of a tuple according to a list of indices

Definition at line 73 of file TupleElements.hpp.

template<int N, typename Tp , TypeIf<(isTuple< Tp >), void * > = nullptr>
decltype(auto) SUNphi::getTail ( const Tp &&  tp)

Gets the tail of a Tuple

Return a Tuple containg the last N elements of a tuple

Number of elements in the tuple

Beginning of returned part

Parameters
tpTuple from which to extract

Definition at line 98 of file TupleElements.hpp.