Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
variadic-helper.hpp File Reference

Metaprogramming with type sequences based on variadic template parameters. More...

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.

Remarks
in Lumiera, over time three different approaches were developed for handling sequences of types in metaprogramming; some of these techniques are better suited for specific kinds of tasks than others
  • templates with variadic arguments (e.g. std::tuple) can be manipulated directly
  • a type-sequence Types<T...> can be primed / rebound from other variadic templates
  • Loki-style type-lists are created from type-sequences and enable elaborate manipulations
See also
feed-manifold.hpp advanced usage example in the Render Engine
TupleHelper_test
typelist.hpp
function.hpp
generator.hpp

Definition in file variadic-helper.hpp.

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::meta
 
namespace  lib::meta::anonymous_namespace{variadic-helper.hpp}
 

Classes

struct  IndexSeq< idx >
 Hold a sequence of index numbers as template parameters. More...
 
struct  BuildIndexSeq< n >
 build regular sequences of index number e.g. More...
 
struct  BuildIndexSeq< 0 >
 
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  ElmTypes< X, typename >
 Variadic type sequence builder. More...
 
struct  ElmTypes< Types< TYPES... > >
 Partial specialisation to handle type sequences. More...
 
class  WithIdxSeq< N >
 helper to invoke a functor, passing instances of std::integral_constant More...
 
struct  SelectVararg< i >
 
struct  SelectVararg< 0 >
 
struct  SelectOrInit< bool, typename, idx >
 
struct  SelectOrInit< false, DEFAULT, idx >
 

Functions

template<class TTX , class FUN >
void forEachIDX (FUN &&fun)
 Invoke a function (or λ) with index numbers derived from some variadic count.
 
template<class TTX , class FUN >
bool andAllIDX (FUN &&fun)
 
template<class TTX , class FUN >
bool orAnyIDX (FUN &&fun)
 
template<size_t idx, typename... ARGS>
constexpr auto pickArg (ARGS &&... args)
 Helper to single out one argument from a variadic argument pack.
 
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.
 

Class Documentation

◆ lib::meta::IndexSeq

struct lib::meta::IndexSeq
Class Members
typedef IndexSeq< idx..., i > AppendElm
typedef IndexSeq< i, idx... > PrependElm
+ Collaboration diagram for IndexSeq< idx >:

◆ lib::meta::BuildIndexSeq

struct lib::meta::BuildIndexSeq
Class Members
typedef template AppendElm< n-1 > Ascending
typedef template PrependElm< n-1 > Descending
typedef template template AppendElm< n-1+d > OffsetBy
typedef template template AppendElm< x > FilledWith
typedef Ascending First
typedef BuildIndexSeq<(n >c)? n-c :0 >::template OffsetBy< c > After
+ Collaboration diagram for BuildIndexSeq< n >:

◆ lib::meta::BuildIndexSeq< 0 >

struct lib::meta::BuildIndexSeq< 0 >
Class Members
typedef IndexSeq<> EmptySeq
typedef EmptySeq Ascending
typedef EmptySeq Descending
typedef EmptySeq OffsetBy
typedef EmptySeq FilledWith
typedef EmptySeq First
typedef EmptySeq After
+ Collaboration diagram for BuildIndexSeq< 0 >: