tlx
Meta-Template Programming

Tools for easier meta-template programming. More...

Namespaces

 tlx::meta_detail
 

Classes

struct  enable_if< bool, T >
 SFINAE enable_if – copy of std::enable_if<> with less extra cruft. More...
 
struct  enable_if< true, T >
 
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  make_index_sequence< Size >
 
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  Log2Floor< Input >
 
class  Log2Floor< 1 >
 
class  Log2Floor< 0 >
 
class  Log2< Input >
 
class  Log2< 1 >
 
class  Log2< 0 >
 
class  NoOperation< ReturnType >
 The noop functor, which takes any arguments and does nothing. More...
 
class  NoOperation< void >
 Specialized noop functor which returns a void. More...
 
struct  StaticIndex< Index >
 Helper for call_foreach_with_index() to save the index as a compile-time index. More...
 

Macros

#define TLX_MAKE_HAS_MEMBER(Member)
 Macro template for class member / attribute SFINAE test. More...
 
#define TLX_MAKE_HAS_TEMPLATE_MEMBER(Member)
 Macro template for class template member 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_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)
 Call a generic functor (like a generic lambda) for each variadic template argument. More...
 
template<typename Functor , typename Tuple >
void 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. More...
 
template<typename Functor , typename Tuple >
void 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. More...
 
template<typename Functor , typename... Args>
void 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. More...
 
template<typename Reduce , typename Initial , typename... Args>
auto fold_left (Reduce &&r, Initial &&init, Args &&...args)
 Implements fold_left() – ((a * b) * c) – with a binary Reduce operation and initial value. More...
 
template<typename Reduce , typename Initial , typename Tuple >
auto 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. More...
 
template<typename Reduce , typename Initial , typename... Args>
auto fold_right (Reduce &&r, Initial &&init, Args &&...args)
 Implements fold_right() – (a * (b * c)) – with a binary Reduce operation and initial value. More...
 
template<typename Reduce , typename Initial , typename Tuple >
auto 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. More...
 
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)
 Call a generic functor (like a generic lambda) for each variadic template argument. More...
 
template<typename Functor , typename Tuple >
auto 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<>. More...
 
template<typename Functor , typename Tuple >
auto 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<>. More...
 
template<typename Functor , typename... Args>
auto 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. More...
 

Detailed Description

Tools for easier meta-template programming.

Macro Definition Documentation

#define TLX_MAKE_HAS_MEMBER (   Member)

Macro template for class member / attribute SFINAE test.

Usage:

1 TLX_MAKE_HAS_METHOD(myfunc);
2 
3 static_assert(has_method_myfunc<MyClass>::value,
4  "check MyClass for existence of attribute/method myfunc");

Definition at line 36 of file has_member.hpp.

#define TLX_MAKE_HAS_METHOD (   Method)

Macro template for callable class method SFINAE test.

Usage:

1 TLX_MAKE_HAS_METHOD(myfunc);
2 
3 static_assert(has_method_myfunc<MyClass, int(std::string)>::value,
4  "check MyClass for existence of myfunc "
5  "with signature int(std::string)");

Definition at line 34 of file has_method.hpp.

#define TLX_MAKE_HAS_STATIC_METHOD (   Method)

Macro template for callable class method SFINAE test.

Usage:

1 TLX_MAKE_HAS_STATIC_METHOD(myfunc);
2 
3 static_assert(has_method_myfunc<MyClass, int(std::string)>::value,
4  "check MyClass for existence of static myfunc "
5  "with signature int(std::string)");

Definition at line 62 of file has_method.hpp.

#define TLX_MAKE_HAS_TEMPLATE_MEMBER (   Member)

Macro template for class template member SFINAE test.

Usage:

1 TLX_MAKE_HAS_TEMPLATE_METHOD(myfunc);
2 
3 static_assert(has_method_myfunc<MyClass, float, int>::value,
4  "check MyClass for existence of attribute/method myfunc "
5  "if instantiated with <float, int>");

Definition at line 61 of file has_member.hpp.

#define TLX_MAKE_HAS_TEMPLATE_METHOD (   Method)

Macro template for callable class method SFINAE test.

Usage:

1 TLX_MAKE_HAS_TEMPLATE_METHOD(myfunc);
2 
3 static_assert(has_method_myfunc<MyClass, int(std::string), float, int>::value,
4  "check MyClass for existence of template myfunc "
5  "with signature int(std::string) "
6  "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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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 &&  ...)

Definition at line 24 of file vexpand.hpp.

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.

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.

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.

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.

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.

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.