tlx
Loading...
Searching...
No Matches
Meta-Template Programming

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

Namespaces

namespace  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.
#define TLX_MAKE_HAS_TEMPLATE_MEMBER(Member)
 Macro template for class template member SFINAE test.
#define TLX_MAKE_HAS_METHOD(Method)
 Macro template for callable class method SFINAE test.
#define TLX_MAKE_HAS_STATIC_METHOD(Method)
 Macro template for callable class method SFINAE test.
#define TLX_MAKE_HAS_TEMPLATE_METHOD(Method)
 Macro template for callable class method SFINAE test.

Functions

template<typename Functor, typename Tuple>
auto apply_tuple (Functor &&f, Tuple &&t)
 Call the functor f with the contents of t as arguments.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.
template<typename Functor>
static auto make_function_chain (const Functor &functor)
 Functor chain maker. Can also be called with a lambda function.
static auto make_function_chain ()
 Construct and empty function chain.
template<typename Input, typename Functor>
static auto make_function_stack (const Functor &functor)
 Function-style construction of a FunctionStack.
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).
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).
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.
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<>.
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<>.
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.

Detailed Description

Tools for easier meta-template programming.

Macro Definition Documentation

◆ TLX_MAKE_HAS_MEMBER

#define TLX_MAKE_HAS_MEMBER ( Member)

Macro template for class member / attribute SFINAE test.

Usage:

static_assert(has_method_myfunc<MyClass>::value,
"check MyClass for existence of attribute/method myfunc");
#define TLX_MAKE_HAS_METHOD(Method)
Macro template for callable class method SFINAE test.

Definition at line 36 of file has_member.hpp.

◆ TLX_MAKE_HAS_METHOD

#define TLX_MAKE_HAS_METHOD ( Method)

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.

◆ TLX_MAKE_HAS_STATIC_METHOD

#define TLX_MAKE_HAS_STATIC_METHOD ( Method)

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)");
#define TLX_MAKE_HAS_STATIC_METHOD(Method)
Macro template for callable class method SFINAE test.

Definition at line 62 of file has_method.hpp.

◆ TLX_MAKE_HAS_TEMPLATE_MEMBER

#define TLX_MAKE_HAS_TEMPLATE_MEMBER ( Member)

Macro template for class template member SFINAE test.

Usage:

static_assert(has_method_myfunc<MyClass, float, int>::value,
"check MyClass for existence of attribute/method myfunc "
"if instantiated with <float, int>");
#define TLX_MAKE_HAS_TEMPLATE_METHOD(Method)
Macro template for callable class method SFINAE test.

Definition at line 61 of file has_member.hpp.

◆ TLX_MAKE_HAS_TEMPLATE_METHOD

#define TLX_MAKE_HAS_TEMPLATE_METHOD ( Method)

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

◆ apply_tuple()

template<typename Functor, typename Tuple>
auto 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.

◆ call_for_range() [1/2]

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

Definition at line 55 of file call_for_range.hpp.

◆ call_for_range() [2/2]

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

Definition at line 62 of file call_for_range.hpp.

◆ call_foreach()

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.

Definition at line 47 of file call_foreach.hpp.

◆ call_foreach_tuple()

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.

Definition at line 45 of file call_foreach_tuple.hpp.

◆ call_foreach_tuple_with_index()

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.

Definition at line 45 of file call_foreach_tuple_with_index.hpp.

◆ call_foreach_with_index()

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.

Definition at line 50 of file call_foreach_with_index.hpp.

◆ fold_left()

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.

Definition at line 51 of file fold_left.hpp.

◆ fold_left_tuple()

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.

Definition at line 43 of file fold_left_tuple.hpp.

◆ fold_right()

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.

Definition at line 50 of file fold_right.hpp.

◆ fold_right_tuple()

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.

Definition at line 42 of file fold_right_tuple.hpp.

◆ make_function_chain() [1/2]

auto make_function_chain ( )
inlinestatic

Construct and empty function chain.

Definition at line 178 of file function_chain.hpp.

◆ make_function_chain() [2/2]

template<typename Functor>
auto 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.

◆ make_function_stack()

template<typename Input, typename Functor>
auto make_function_stack ( const Functor & functor)
inlinestatic

Function-style construction of a FunctionStack.

Definition at line 170 of file function_stack.hpp.

◆ vexpand()

template<typename... Types>
void vexpand ( Types && ...)

Definition at line 24 of file vexpand.hpp.

◆ vmap_for_range() [1/2]

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

Definition at line 62 of file vmap_for_range.hpp.

◆ vmap_for_range() [2/2]

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

Definition at line 69 of file vmap_for_range.hpp.

◆ vmap_foreach()

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.

Definition at line 51 of file vmap_foreach.hpp.

◆ vmap_foreach_tuple()

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

Definition at line 43 of file vmap_foreach_tuple.hpp.

◆ vmap_foreach_tuple_with_index()

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

Definition at line 45 of file vmap_foreach_tuple_with_index.hpp.

◆ vmap_foreach_with_index()

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.

Definition at line 56 of file vmap_foreach_with_index.hpp.