Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Meta-Template Programming
+ Collaboration diagram for Meta-Template Programming:

Namespaces

 tlx::meta_detail
 

Classes

class  FunctionChain< Functors >
 A FunctionChain is a chain of functors that can be folded to a single functors. More...
 
class  FunctionStack< Input_, Functors >
 A FunctionStack is a chain of functor that can be folded to a single functor (which is usually optimize by the compiler). More...
 
struct  index_sequence< Indexes >
 
struct  is_std_array< T >
 test if is std::array<T, N> More...
 
struct  is_std_array< std::array< T, N > >
 
struct  is_std_pair< T >
 test if is a std::pair<...> More...
 
struct  is_std_pair< std::pair< S, T > >
 
struct  is_std_tuple< T >
 test if is a std::tuple<...> More...
 
struct  is_std_tuple< std::tuple< Ts...> >
 
struct  is_std_vector< T >
 test if is std::vector<T> More...
 
struct  is_std_vector< std::vector< T > >
 
class  Log2< Input >
 
class  Log2< 0 >
 
class  Log2< 1 >
 
class  Log2Floor< Input >
 
class  Log2Floor< 0 >
 
class  Log2Floor< 1 >
 
struct  make_index_sequence< Size >
 
struct  StaticIndex< Index >
 

Macros

#define TLX_MAKE_HAS_MEMBER(Member)
 Macro template for class member / attribute SFINAE test. More...
 
#define TLX_MAKE_HAS_METHOD(Method)
 Macro template for callable class method SFINAE test. More...
 
#define TLX_MAKE_HAS_STATIC_METHOD(Method)
 Macro template for callable class method SFINAE test. More...
 
#define TLX_MAKE_HAS_TEMPLATE_MEMBER(Member)
 Macro template for class template member SFINAE test. More...
 
#define TLX_MAKE_HAS_TEMPLATE_METHOD(Method)
 Macro template for callable class method SFINAE test. More...
 

Functions

template<typename Functor , typename Tuple >
auto apply_tuple (Functor &&f, Tuple &&t)
 Call the functor f with the contents of t as arguments. More...
 
template<size_t Size, typename Functor >
void call_for_range (Functor &&f)
 Call a generic functor (like a generic lambda) for the integers [0,Size). More...
 
template<size_t Begin, size_t End, typename Functor >
void call_for_range (Functor &&f)
 Call a generic functor (like a generic lambda) for the integers [Begin,End). More...
 
template<typename Functor , typename... Args>
void call_foreach (Functor &&f, Args &&...args)
 
template<typename Functor , typename Tuple >
void call_foreach_tuple (Functor &&f, Tuple &&t)
 
template<typename Functor , typename Tuple >
void call_foreach_tuple_with_index (Functor &&f, Tuple &&t)
 
template<typename Functor , typename... Args>
void call_foreach_with_index (Functor &&f, Args &&...args)
 
template<typename Reduce , typename Initial , typename... Args>
auto fold_left (Reduce &&r, Initial &&init, Args &&...args)
 
template<typename Reduce , typename Initial , typename Tuple >
auto fold_left_tuple (Reduce &&r, Initial &&init, Tuple &&t)
 
template<typename Reduce , typename Initial , typename... Args>
auto fold_right (Reduce &&r, Initial &&init, Args &&...args)
 
template<typename Reduce , typename Initial , typename Tuple >
auto fold_right_tuple (Reduce &&r, Initial &&init, Tuple &&t)
 
template<typename Functor >
static auto make_function_chain (const Functor &functor)
 Functor chain maker. Can also be called with a lambda function. More...
 
static auto make_function_chain ()
 Construct and empty function chain. More...
 
template<typename Input , typename Functor >
static auto make_function_stack (const Functor &functor)
 Function-style construction of a FunctionStack. More...
 
template<typename... Types>
void vexpand (Types &&...)
 
template<size_t Size, typename Functor >
auto vmap_for_range (Functor &&f)
 Vmap a generic functor (like a generic lambda) for the integers [0,Size). More...
 
template<size_t Begin, size_t End, typename Functor >
auto vmap_for_range (Functor &&f)
 Vmap a generic functor (like a generic lambda) for the integers [Begin,End). More...
 
template<typename Functor , typename... Args>
auto vmap_foreach (Functor &&f, Args &&...args)
 
template<typename Functor , typename Tuple >
auto vmap_foreach_tuple (Functor &&f, Tuple &&t)
 
template<typename Functor , typename Tuple >
auto vmap_foreach_tuple_with_index (Functor &&f, Tuple &&t)
 
template<typename Functor , typename... Args>
auto vmap_foreach_with_index (Functor &&f, Args &&...args)
 

Detailed Description

Tools for easier meta-template programming

Macro Definition Documentation

#define TLX_MAKE_HAS_MEMBER (   Member)
Value:
template <typename Type> \
class has_member_ ## Member \
{ \
template <typename C> \
static char test(decltype(&C::Member)); \
template <typename C> \
static int test(...); \
public: \
static const bool value = ( /* NOLINT */ \
sizeof(test<Type>(0)) == sizeof(char)); \
}
int value
Definition: gen_data.py:41

Macro template for class member / attribute SFINAE test.

Usage:

"check MyClass for existence of attribute/method myfunc");

Definition at line 36 of file has_member.hpp.

#define TLX_MAKE_HAS_METHOD (   Method)
Value:
template <typename Class, typename Signature> \
class has_method_ ## Method; \
\
template <typename Class, typename Return, typename... Args> \
class has_method_ ## Method<Class, Return(Args...)> \
{ \
template <typename C> \
static char test( \
decltype(static_cast<Return (C::*)(Args...)>(&C::Method))); \
template <typename C> \
static int test(...); \
public: \
static const bool value = (sizeof(test<Class>(0)) == sizeof(char)); \
}
int value
Definition: gen_data.py:41

Macro template for callable class method SFINAE test.

Usage:

static_assert(has_method_myfunc<MyClass, int(std::string)>::value,
"check MyClass for existence of myfunc "
"with signature int(std::string)");

Definition at line 34 of file has_method.hpp.

#define TLX_MAKE_HAS_STATIC_METHOD (   Method)
Value:
template <typename Class, typename Signature> \
class has_method_ ## Method; \
\
template <typename Class, typename Return, typename... Args> \
class has_method_ ## Method<Class, Return(Args...)> \
{ \
template <typename C> \
static char test( \
decltype(static_cast<Return (*)(Args...)>(&C::Method))); \
template <typename C> \
static int test(...); \
public: \
static const bool value = (sizeof(test<Class>(0)) == sizeof(char)); \
}
int value
Definition: gen_data.py:41

Macro template for callable class method SFINAE test.

Usage:

static_assert(has_method_myfunc<MyClass, int(std::string)>::value,
"check MyClass for existence of static myfunc "
"with signature int(std::string)");

Definition at line 62 of file has_method.hpp.

#define TLX_MAKE_HAS_TEMPLATE_MEMBER (   Member)
Value:
template <typename Type, typename... Args> \
class has_member_ ## Member \
{ \
template <typename C> \
static char test(decltype(&C::template Member<Args...>)); \
template <typename C> \
static int test(...); \
public: \
static const bool value = ( /* NOLINT */ \
sizeof(test<Type>(0)) == sizeof(char)); \
}
Type
VFS object type.
Definition: file_io.hpp:52
int value
Definition: gen_data.py:41

Macro template for class template member SFINAE test.

Usage:

"check MyClass for existence of attribute/method myfunc "
"if instantiated with <float, int>");

Definition at line 61 of file has_member.hpp.

#define TLX_MAKE_HAS_TEMPLATE_METHOD (   Method)
Value:
template <typename Class, typename Signature, typename... Cons> \
class has_method_ ## Method; \
\
template <typename Class, \
typename Return, typename... Args, typename... Cons> \
class has_method_ ## Method<Class, Return(Args...), Cons...> \
{ \
template <typename C> \
static char test( \
decltype(static_cast<Return (C::*)(Args...)>( \
&C::template Method<Cons...>))); \
template <typename C> \
static int test(...); \
public: \
static const bool value = (sizeof(test<Class>(0)) == sizeof(char)); \
}
int value
Definition: gen_data.py:41

Macro template for callable class method SFINAE test.

Usage:

static_assert(has_method_myfunc<MyClass, int(std::string), float, int>::value,
"check MyClass for existence of template myfunc "
"with signature int(std::string) "
"if the template method is instantiated with <float, int>");

Definition at line 91 of file has_method.hpp.

Function Documentation

auto tlx::apply_tuple ( Functor &&  f,
Tuple &&  t 
)

Call the functor f with the contents of t as arguments.

Definition at line 40 of file apply_tuple.hpp.

References tlx::meta_detail::apply_tuple_impl(), and gen_data::value.

void tlx::call_for_range ( Functor &&  f)

Call a generic functor (like a generic lambda) for the integers [0,Size).

Definition at line 55 of file call_for_range.hpp.

References CallForRangeImpl< Index, Size, Functor >::call().

void tlx::call_for_range ( Functor &&  f)

Call a generic functor (like a generic lambda) for the integers [Begin,End).

Definition at line 62 of file call_for_range.hpp.

References CallForRangeImpl< Index, Size, Functor >::call().

void tlx::call_foreach ( Functor &&  f,
Args &&...  args 
)

Call a generic functor (like a generic lambda) for each variadic template argument.

Definition at line 47 of file call_foreach.hpp.

References tlx::meta_detail::call_foreach_impl().

Referenced by tlx::meta_detail::call_foreach_tuple_impl(), and JsonLogger::JsonLogger().

void tlx::call_foreach_tuple ( Functor &&  f,
Tuple &&  t 
)

Call a generic functor (like a generic lambda) to each components of a tuple together with its zero-based index.

Definition at line 45 of file call_foreach_tuple.hpp.

References tlx::meta_detail::call_foreach_tuple_impl(), and gen_data::value.

void tlx::call_foreach_tuple_with_index ( Functor &&  f,
Tuple &&  t 
)

Call a generic functor (like a generic lambda) to each components of a tuple together with its zero-based index.

Definition at line 45 of file call_foreach_tuple_with_index.hpp.

References tlx::meta_detail::call_foreach_tuple_with_index_impl(), and gen_data::value.

Referenced by LoggerFormatter< std::tuple< Args...> >::print().

void tlx::call_foreach_with_index ( Functor &&  f,
Args &&...  args 
)

Call a generic functor (like a generic lambda) for each variadic template argument together with its zero-based index.

Definition at line 50 of file call_foreach_with_index.hpp.

Referenced by tlx::meta_detail::call_foreach_tuple_with_index_impl().

auto tlx::fold_left ( Reduce &&  r,
Initial &&  init,
Args &&...  args 
)

Implements fold_left() – ((a * b) * c) – with a binary Reduce operation and initial value.

Definition at line 51 of file fold_left.hpp.

References tlx::meta_detail::fold_left_impl().

Referenced by tlx::meta_detail::fold_left_tuple_impl().

auto tlx::fold_left_tuple ( Reduce &&  r,
Initial &&  init,
Tuple &&  t 
)

Implements fold_left() – ((a * b) * c) – with a binary Reduce operation and initial value on a tuple.

Definition at line 43 of file fold_left_tuple.hpp.

References tlx::meta_detail::fold_left_tuple_impl(), and gen_data::value.

auto tlx::fold_right ( Reduce &&  r,
Initial &&  init,
Args &&...  args 
)

Implements fold_right() – (a * (b * c)) – with a binary Reduce operation and initial value.

Definition at line 50 of file fold_right.hpp.

References tlx::meta_detail::fold_right_impl().

Referenced by tlx::meta_detail::fold_right_tuple_impl().

auto tlx::fold_right_tuple ( Reduce &&  r,
Initial &&  init,
Tuple &&  t 
)

Implements fold_right() – (a * (b * c)) – with a binary Reduce operation and initial value on a tuple.

Definition at line 42 of file fold_right_tuple.hpp.

References tlx::meta_detail::fold_right_tuple_impl(), and gen_data::value.

static auto tlx::make_function_chain ( const Functor &  functor)
inlinestatic

Functor chain maker. Can also be called with a lambda function.

Definition at line 172 of file function_chain.hpp.

static auto tlx::make_function_chain ( )
inlinestatic

Construct and empty function chain.

Definition at line 178 of file function_chain.hpp.

static auto tlx::make_function_stack ( const Functor &  functor)
inlinestatic

Function-style construction of a FunctionStack.

Definition at line 170 of file function_stack.hpp.

void tlx::vexpand ( Types &&  ...)
auto tlx::vmap_for_range ( Functor &&  f)

Vmap a generic functor (like a generic lambda) for the integers [0,Size).

Definition at line 62 of file vmap_for_range.hpp.

References VMapForRangeImpl< Index, Size, Functor >::call().

auto tlx::vmap_for_range ( Functor &&  f)

Vmap a generic functor (like a generic lambda) for the integers [Begin,End).

Definition at line 69 of file vmap_for_range.hpp.

References VMapForRangeImpl< Index, Size, Functor >::call().

auto tlx::vmap_foreach ( Functor &&  f,
Args &&...  args 
)

Call a generic functor (like a generic lambda) for each variadic template argument.

Definition at line 51 of file vmap_foreach.hpp.

References tlx::meta_detail::vmap_foreach_impl().

Referenced by tlx::meta_detail::vmap_foreach_tuple_impl().

auto tlx::vmap_foreach_tuple ( Functor &&  f,
Tuple &&  t 
)

Call a generic functor (like a generic lambda) for each variadic template argument and collect the result in a std::tuple<>.

Definition at line 43 of file vmap_foreach_tuple.hpp.

References gen_data::value, and tlx::meta_detail::vmap_foreach_tuple_impl().

auto tlx::vmap_foreach_tuple_with_index ( Functor &&  f,
Tuple &&  t 
)

Call a generic functor (like a generic lambda) for each variadic template argument and collect the result in a std::tuple<>.

Definition at line 45 of file vmap_foreach_tuple_with_index.hpp.

References gen_data::value, and tlx::meta_detail::vmap_foreach_tuple_with_index_impl().

auto tlx::vmap_foreach_with_index ( Functor &&  f,
Args &&...  args 
)

Call a generic functor (like a generic lambda) for each variadic template argument together with its zero-based index.

Definition at line 56 of file vmap_foreach_with_index.hpp.

Referenced by tlx::meta_detail::vmap_foreach_tuple_with_index_impl().