SUNphi  1.0
TupleClass.hpp File Reference

Define Tuple. More...

#include <tuple>
#include <ints/IntSeq.hpp>
#include <metaprogramming/TypeTraits.hpp>

Go to the source code of this file.

Classes

struct  SUNphi::_isTuple< T >
 
struct  SUNphi::_isTuple< Tuple< Tp... > >
 
struct  SUNphi::ConstrainIsTuple< T >
 Constrain the class T to be a Tuple. More...
 
struct  SUNphi::ConstrainTupleTypesAreAllDifferent< T, class >
 Constrain all types in the tuple to be different. More...
 
struct  SUNphi::ConstrainTupleHasType< T, TP, class >
 Constrain a type T to be contained in a Tuple. More...
 
struct  SUNphi::ConstrainTupleHasNotType< T, TP, class >
 Constrain a type T to be not contained in a Tuple. More...
 

Macros

#define STATIC_ASSERT_IS_TUPLE(T)   static_assert(isTuple<T>,"Type is not a tuple")
 Assert if the type is not a Tuple.
 
#define DEFINE_VARIADIC_TYPE_FROM_TUPLE(TYPE)
 
#define STATIC_ASSERT_TUPLE_TYPES_ARE_ALL_DIFFERENT(T)   static_assert(tupleTypesAreAllDifferent<T>,"Types in the tuple are not all different")
 Assert if the Tuple contains multiple times a given type.
 
#define STATIC_ASSERT_TUPLE_HAS_TYPE(T, TP)   static_assert(tupleHasType<T,TP>,"Searched type not found")
 Assert if the type T is not in the types of tuple TP.
 
#define STATIC_ASSERT_TUPLE_HAS_NOT_TYPE(T, TP)   static_assert(not tupleHasType<T,TP>,"Searched type found")
 Assert if the type T is in the types of tuple TP.
 

Typedefs

template<class... Tp>
using SUNphi::Tuple = std::tuple< Tp... >
 
template<int I, typename Tp , typename = EnableIf<isTuple<Tp>>>
using SUNphi::TupleElementType = typename std::tuple_element< I, Tp >::type
 Returns the type of the element I of the Tuple Tp.
 

Functions

template<typename T , typename... Tp>
constexpr bool SUNphi::_tupleHasType (T, Tuple< Tp... >)
 
template<typename... ToBeSearchedTypes, typename... ContainingTypes>
constexpr bool SUNphi::_tupleHasTypes (Tuple< ToBeSearchedTypes... >, Tuple< ContainingTypes... >)
 

Variables

template<class T >
constexpr int SUNphi::isTuple
 
template<typename T >
constexpr int SUNphi::tupleSize
 Total number of elements in a Tuple. More...
 
template<class T1 , class T2 , class = FalseType>
static constexpr int SUNphi::_nOfTypeInTuple
 
template<class T , class... Tp>
static constexpr int SUNphi::_nOfTypeInTuple< T, Tuple< Tp... > >
 
template<class T , class TP , class = ConstrainIsTuple<TP>>
static constexpr int SUNphi::nOfTypeInTuple
 
template<class T , class = ConstrainIsTuple<T>>
static constexpr int SUNphi::nDiffTypesInTuple
 
template<class... Tp>
static constexpr int SUNphi::nDiffTypesInTuple< Tuple< Tp... > >
 
template<class T , class = ConstrainIsTuple<T>>
static constexpr bool SUNphi::tupleTypesAreAllDifferent
 Check whether all types of a Tuple are different. More...
 
template<typename T , typename Tp , typename = ConstrainIsTuple<Tp>>
constexpr bool SUNphi::tupleHasType
 Return true if Tuple Tp contains the type T. More...
 
template<typename TpToSearch , typename TpContaining >
constexpr bool SUNphi::tupleHasTypes
 

Detailed Description

Define Tuple.

Definition in file TupleClass.hpp.

Macro Definition Documentation

#define DEFINE_VARIADIC_TYPE_FROM_TUPLE (   TYPE)
Value:
\ \ \ \
template <class TP, \
class=FalseType> \
struct _ ## TYPE ## FromTuple; \
\ \ \ \
template <class...Tp> \
struct _ ## TYPE ## FromTuple<Tuple<Tp...>> \
{ \
\ \
using type=TYPE<Tp...>; \
}; \
\ \ \ \
template <class TP, \
class=ConstrainIsTuple<TP>> \
using TYPE ## FromTuple=typename _ ## TYPE ## FromTuple<TP>::type
std::tuple< Tp... > Tuple
Definition: TupleClass.hpp:20
std::false_type FalseType
Definition: TypeTraits.hpp:30

Define a Variadic type taking all types of a tuple as list of parameters

Example:

1 template <class...Tp>
2 struct Test
3 {
4  int size=sizeof...(Tp);
5 };
6 
7 DEFINE_VARIADIC_TYPE_FROM_TUPLE(Test);
8 
9 int size=TestFromTuple<Tuple<int,char>>::size; //2

Definition at line 94 of file TupleClass.hpp.

Typedef Documentation

template<class... Tp>
using SUNphi::Tuple = typedef std::tuple<Tp...>

Define Tuple, a list of arbitrary types.

Directly aliasing the std library.

Definition at line 20 of file TupleClass.hpp.

Function Documentation

template<typename T , typename... Tp>
constexpr bool SUNphi::_tupleHasType ( ,
Tuple< Tp... >   
)

Return true if Tuple Tp contains the type T

Internal implementation

Definition at line 196 of file TupleClass.hpp.

template<typename... ToBeSearchedTypes, typename... ContainingTypes>
constexpr bool SUNphi::_tupleHasTypes ( Tuple< ToBeSearchedTypes... >  ,
Tuple< ContainingTypes... >   
)

Checks that a tuple is contained into another one

Internal implementation

Definition at line 244 of file TupleClass.hpp.

Variable Documentation

template<class T1 , class T2 , class = FalseType>
constexpr int SUNphi::_nOfTypeInTuple
static
Initial value:
=
0

Counts the same types

Single pair of types case - forbids implementation

Definition at line 130 of file TupleClass.hpp.

template<class T , class... Tp>
constexpr int SUNphi::_nOfTypeInTuple< T, Tuple< Tp... > >
static
Initial value:
=
hSum<isSame<T,Tp>...>

Counts the same type

Counts the occurrency of type T inside a tuple

Definition at line 138 of file TupleClass.hpp.

template<class T >
constexpr int SUNphi::isTuple
Initial value:
=
_isTuple<Unqualified<T>>::value

Check that a type is a tuple

Gives visibility to the internal implementation

Definition at line 45 of file TupleClass.hpp.

template<class T , class = ConstrainIsTuple<T>>
constexpr int SUNphi::nDiffTypesInTuple
static
Initial value:
=
0

Count the number of different types in a Tuple

Generic type - forbids instantiation

Definition at line 159 of file TupleClass.hpp.

template<class... Tp>
constexpr int SUNphi::nDiffTypesInTuple< Tuple< Tp... > >
static
Initial value:
=
IntSeq<(nOfTypeInTuple<Tp,Tuple<Tp...>> ==1)...>::hSum
std::tuple< Tp... > Tuple
Definition: TupleClass.hpp:20
static constexpr int nOfTypeInTuple
Definition: TupleClass.hpp:148

Count the number of different types in a Tuple

Real tuple case

Definition at line 166 of file TupleClass.hpp.

template<class T , class TP , class = ConstrainIsTuple<TP>>
constexpr int SUNphi::nOfTypeInTuple
static
Initial value:
=
_nOfTypeInTuple<T,TP>

Counts the same type

Gives external visibility to the implementation

Definition at line 148 of file TupleClass.hpp.

template<typename T , typename Tp , typename = ConstrainIsTuple<Tp>>
constexpr bool SUNphi::tupleHasType
Initial value:
=
_tupleHasType(T{},Tp{})
Tens< Tk, double > T
Tensor class of the expression.
Definition: RelBind.hpp:263
constexpr bool _tupleHasType(T, Tuple< Tp... >)
Definition: TupleClass.hpp:196

Return true if Tuple Tp contains the type T.

Definition at line 207 of file TupleClass.hpp.

template<typename TpToSearch , typename TpContaining >
constexpr bool SUNphi::tupleHasTypes
Initial value:
=
_tupleHasTypes(TpToSearch{},TpContaining{})
constexpr bool _tupleHasTypes(Tuple< ToBeSearchedTypes... >, Tuple< ContainingTypes... >)
Definition: TupleClass.hpp:244

Checks that a tuple is contained into another one

Gives visibility to the internal implementation

Definition at line 256 of file TupleClass.hpp.

template<typename T >
constexpr int SUNphi::tupleSize
Initial value:
=
std::tuple_size<Unqualified<T>>::value

Total number of elements in a Tuple.

Definition at line 73 of file TupleClass.hpp.

template<class T , class = ConstrainIsTuple<T>>
constexpr bool SUNphi::tupleTypesAreAllDifferent
static
Initial value:
=
(nDiffTypesInTuple<T> ==tupleSize<T>)

Check whether all types of a Tuple are different.

Definition at line 175 of file TupleClass.hpp.