Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
variadic-rebind.hpp File Reference

Metaprogramming support to rebuild and rebind variadic templates. More...

Go to the source code of this file.

Description

Metaprogramming support to rebuild and rebind variadic templates.

The sequence of variadic arguments itself is often difficult to manipulate, because a parameter pack is not a type proper in C++, but rather some meta mapping expanded immediately by the compiler. For more elaborate processing, this sequence must thus be re-mapped into a format that allows to pass partial results from recursive evaluations (since all of this »processing« is actually a form of functional programming).

For many simple cases though it is sufficient just to re-bind a template to another template's variadic sequence, possibly with some basic manipulation. Such a meta-processing can be coded very succinctly, by passing the target template to receive the altered sequence as a template-template parameter.

Warning
this kind of recursive remoulding typically imposes an O(n) effort during compilation, sometimes even O(n²) (notably reversing a sequence). Thus be sure to apply to short type sequences only endcode
Usage example
template<typename...CASES>
struct MyModel
{
using SubSeq = _Vari<MyModel, CASES...>::Prefix;
// adapt a predecessor sequence
MyModel (SubSeq&& subModel);
using Tuple = RebindVariadic<std::tuple, CASES...>::Type;
}
#define Type(_EXPR_)
See also
param-weaving-pattern.hpp "usage example"
util::parse::AltModel "usage example"
typelist.hpp
function.hpp

Definition in file variadic-rebind.hpp.

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::meta
 

Classes

struct  RebindVariadic< X, ARGS >
 Metaprogramming helper to transfer variadic arguments. More...
 
struct  RebindVariadic< X, U< ARGS... > >
 
struct  _Vari< L, X, L< XS... > >
 
struct  _Vari< L, X1, X2 >
 
struct  _Vari< L, X >
 
struct  _Vari< L, X, XS... >
 

Class Documentation

◆ lib::meta::RebindVariadic

struct lib::meta::RebindVariadic
Class Members
typedef X< ARGS... > Type
+ Collaboration diagram for RebindVariadic< X, ARGS >:

◆ lib::meta::RebindVariadic< X, U< ARGS... > >

struct lib::meta::RebindVariadic< X, U< ARGS... > >
Class Members
typedef X< ARGS... > Type
+ Collaboration diagram for RebindVariadic< X, U< ARGS... > >:

◆ lib::meta::_Vari< L, X, L< XS... > >

struct lib::meta::_Vari< L, X, L< XS... > >
Class Members
typedef L< X, XS... > Prepend
typedef L< XS..., X > Append
+ Collaboration diagram for _Vari< L, X, L< XS... > >:

◆ lib::meta::_Vari< L, X1, X2 >

struct lib::meta::_Vari< L, X1, X2 >
Class Members
typedef X1 Penult
typedef X2 Ultima
typedef L< X1 > Prefix
typedef L< X2 > Remain
typedef L< X2, X1 > Revers
+ Collaboration diagram for _Vari< L, X1, X2 >:

◆ lib::meta::_Vari< L, X >

struct lib::meta::_Vari< L, X >
Class Members
typedef X Ultima
typedef Nil Penult marker for undefined
typedef L< X > Remain
typedef L< X > Revers
typedef L<> Prefix
+ Collaboration diagram for _Vari< L, X >:

◆ lib::meta::_Vari< L, X, XS... >

struct lib::meta::_Vari< L, X, XS... >
Class Members
typedef Penult Penult
typedef Ultima Ultima
typedef Prefix _Tail_Pre_
typedef Revers _Tail_Rev_
typedef L< XS... > Remain
typedef Prepend Prefix
typedef Prepend Revers
+ Collaboration diagram for _Vari< L, X, XS... >: