4 #ifndef CPPQEDCORE_UTILS_TMP_TOOLS_H_INCLUDED
5 #define CPPQEDCORE_UTILS_TMP_TOOLS_H_INCLUDED
15 #ifndef BLITZ_ARRAY_LARGEST_RANK
16 #define BLITZ_ARRAY_LARGEST_RANK 11
17 #endif // BLITZ_ARRAY_LARGEST_RANK
21 #ifndef FUSION_MAX_VECTOR_SIZE
22 #define FUSION_MAX_VECTOR_SIZE 20
23 #endif // FUSION_MAX_VECTOR_SIZE
27 #ifndef FUSION_MAX_LIST_SIZE
28 #define FUSION_MAX_LIST_SIZE FUSION_MAX_VECTOR_SIZE
29 #endif // FUSION_MAX_LIST_SIZE
31 #include <boost/type_traits/add_const.hpp>
32 #include <boost/type_traits/remove_reference.hpp>
33 #include <boost/type_traits/remove_const.hpp>
36 #include <boost/mpl/range_c.hpp>
37 #include <boost/mpl/vector_c.hpp>
38 #include <boost/mpl/vector.hpp>
39 #include <boost/mpl/eval_if.hpp>
40 #include <boost/mpl/identity.hpp>
41 #include <boost/mpl/int.hpp>
42 #include <boost/mpl/find_if.hpp>
43 #include <boost/mpl/equal.hpp>
45 #define DEFINE_TYPED_STATIC_CONST(typeDescription,typeName,variableName) typedef typeDescription typeName; static const typeName variableName;
47 #define DEFINE_INITIALIZE_TYPED_STATIC_CONST(typeDescription,typeName,variableName) typedef typeDescription typeName; static const typeName variableName=typeName();
61 template<
typename T,
bool ADD_CONST>
63 : boost::mpl::eval_if_c<ADD_CONST,boost::add_const<T>,boost::mpl::identity<T> > {};
67 template<
unsigned N,
int Nbeg>
struct Range : boost::mpl::range_c<int,Nbeg,Nbeg+N> {};
75 template<
unsigned N1,
unsigned N2>
struct Power : boost::mpl::int_<N1*Power<N1,N2-1>::value> {};
78 template<
unsigned N1>
struct Power<N1,0> : boost::mpl::int_<1> {};
92 template<
typename Seq,
typename ICW>
94 boost::mpl::equal_to<boost::mpl::_,ICW>
96 typename boost::mpl::end<Seq>::type
101 template<
typename Seq,
typename T, T VALUE>
107 template<
typename T1,
typename T2>
108 struct value_equal : boost::mpl::bool_<T1::value==T2::value>
118 template<
typename Seq1,
typename Seq2>
119 struct numerical_equal : boost::mpl::equal<Seq1,Seq2,details::value_equal<boost::mpl::_1,boost::mpl::_2> >
127 static_assert( 2*(N/2)==N ,
"Argument not even" );
133 template<
int N1,
int N2,
bool IS_EXCLUSIVE=true>
137 template<
int N1,
int N2>
142 static const int first =N1;
143 static const int second=N2;
146 template<
int MIN,
int MAX>
149 static_assert( N1>=MIN && N2>=MIN && N1<=MAX && N2<=MAX ,
"pair_c sanity check failed" );
157 template<
int N1,
int N2>
160 template<
int N1,
int N2>
165 template<
int N1,
int N2>
168 static_assert( N1!=N2 ,
"pair_c with equal elements" );
182 struct ArgumentDispatcher : boost::mpl::integral_c<int,V>
184 static_assert( V>=0 ,
"Negative element in nonnegative vector" );
200 struct Vector : boost::mpl::vector_c<int,details::ArgumentDispatcher<V>::value...> {};
210 #endif // CPPQEDCORE_UTILS_TMP_TOOLS_H_INCLUDED