Lumiera  0.pre.03
»edit your freedom«
variadic-helper.hpp File Reference

Go to the source code of this file.

Description

Metaprogramming with type sequences based on variadic template parameters.

The type rebinding- and helper templates in this header allow to perform simple sequence manipulations on sequences of template parameters extracted from variadic parameter packs. The goal is to (pre)process flexible argument lists at compile time, driven by template instantiation, allowing to specialise and react specifically on some concrete pattern of argument types.

Warning
the metaprogramming part of Lumiera to deal with type sequences is in a state of transition, since C++11 now offers direct language support for processing of flexible template parameter sequences ("parameter packs"). It is planned to regroup and simplify our homemade type sequence framework to rely on variadic templates and integrate better with std::tuple. It is clear that we will retain some parts of our own framework, since programming with Loki-style typelists is way more obvious and straight forward than handling of template parameter packs, since the latter can only be rebound through pattern matching.
Todo:
transition lib::meta::Types to variadic parameters /////////////////////////////////TICKET #987
See also
control::CommandDef usage example
TupleHelper_test
typelist.hpp
function.hpp
generator.hpp

Definition in file variadic-helper.hpp.

Classes

struct  BuildIdxIter< TYPES >
 build a sequence of index numbers based on a type sequence More...
 
struct  BuildIdxIter< Types< TYPES... > >
 build an index number sequence from a type sequence More...
 
struct  BuildIndexSeq< n >
 build regular sequences of index number e.g. More...
 
struct  BuildIndexSeq< 0 >
 
struct  IndexSeq< idx >
 Hold a sequence of index numbers as template parameters. More...
 
struct  Prepend< T, TySeq< TYPES... > >
 temporary workaround: additional specialisation for the template Prepend to work also with the (alternative) variadic TySeq. More...
 
struct  RebindVariadic< X, ARGS >
 Metaprogramming helper to transfer variadic arguments. More...
 
struct  RebindVariadic< X, U< ARGS... > >
 
struct  SelectOrInit< bool, typename, idx >
 
struct  SelectOrInit< false, DEFAULT, idx >
 
struct  SelectVararg< i >
 
struct  SelectVararg< 0 >
 
struct  StripNullType< SEQ >
 temporary workaround: strip trailing NullType entries from a type sequence, to make it compatible with new-style variadic template definitions. More...
 
struct  StripNullType< Types< NullType, TYPES... > >
 
struct  StripNullType< Types< T, TYPES... > >
 
struct  TySeq< TYPES >
 temporary workaround: alternative definition of "type sequence", already using variadic template parameters. More...
 

Functions

template<typename X >
constexpr X const & max (X const &a, X const &b)
 
template<typename X >
constexpr X const & min (X const &a, X const &b)
 
template<size_t idx, typename... ARGS>
constexpr auto pickArg (ARGS &&... args)
 Helper to single out one argument from a variadic argument pack. More...
 
template<size_t idx, typename DEFAULT , typename... ARGS>
constexpr auto pickInit (ARGS &&... args)
 Helper to pick one initialisation argument from a variadic argument pack, falling back to a default constructed element of type DEFAULT in case of insufficient number of variadic arguments. More...
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

Function Documentation

◆ pickArg()

constexpr auto lib::meta::pickArg ( ARGS &&...  args)
inline

Helper to single out one argument from a variadic argument pack.

Template Parameters
idxthe index number (zero based) of the argument to select
Remarks
typically this function is used "driven" by an likewise variadic index sequence, where the index sequence itself is picked up by a pattern match; this usage pattern allows arbitrarily to handle some of the arguments of a variable argument list, as determined by the index sequence passed in.

Definition at line 355 of file variadic-helper.hpp.

References lib::meta::pickArg().

Referenced by lib::meta::pickArg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pickInit()

constexpr auto lib::meta::pickInit ( ARGS &&...  args)
inline

Helper to pick one initialisation argument from a variadic argument pack, falling back to a default constructed element of type DEFAULT in case of insufficient number of variadic arguments.

Template Parameters
idxthe index number (zero based) of the argument to select
DEFALUTtype of the default element to construct as fallback

Definition at line 371 of file variadic-helper.hpp.

References lib::meta::pickInit().

Referenced by lib::meta::pickInit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: