Lumiera  0.pre.03
»edit your freedom«
VariadicArgumentPicker_test Class Reference

Description

Test:
check the basic utilities for manipulating variadic template arguments.
  • single out and pick an argument designated by index
  • pick an argument with fallback on default construction
  • demonstrate usage by reordering the position of arguments

Definition at line 125 of file variadic-argument-picker-test.cpp.

Private Member Functions

void check_pickArg ()
 
void check_pickInit ()
 
void check_reorderedArguments ()
 
virtual void run (Arg)
 
void verify_fixture ()
 

Static Private Member Functions

template<class... ARGS, size_t... idx>
static auto call_with_reversed_arguments (IndexSeq< idx... >, ARGS &&...args)
 Demonstration of argument manipulation through metaprogramming. More...
 

Member Function Documentation

◆ call_with_reversed_arguments()

static auto call_with_reversed_arguments ( IndexSeq< idx... >  ,
ARGS &&...  args 
)
inlinestaticprivate

Demonstration of argument manipulation through metaprogramming.

This function invokes the ubiquitous fun test function with arbitrary arguments, but it re-orders and even prunes arguments as dictated by the Index sequence parameter.

Remarks
Note some fine points:
  • the value of the parameter IndexSeq<idx...> is irrelevant
  • rather, its sole purpose is to pattern match against the type
  • we use IndexSeq just as an container to hold the sequence idx...
  • the expression within the function argument list expands the argument packs
  • and both of them are treated separately
  • the actual arguments are wrapped into a std::forward for perfect forwarding
  • but the key trick of the whole operation lies in the expansion of the idx... pack
  • note that idx without the ... sits within the template list of pickArg<idx>
  • while the corresponding expansion operator is outmost and thus works on the whole expression
  • and thus it is the idx... pack which actually drives the generation of several pickArg instantiations
  • in the end the net effect is that the Index sequence absolutely dictates which arguments are picked

Definition at line 230 of file variadic-argument-picker-test.cpp.

References lib::meta::test::anonymous_namespace{variadic-argument-picker-test.cpp}::fun().

+ Here is the call graph for this function:

◆ check_reorderedArguments()

void check_reorderedArguments ( )
inlineprivate
Test:
demonstrate reordering of arguments

Definition at line 237 of file variadic-argument-picker-test.cpp.

References lib::meta::test::anonymous_namespace{variadic-argument-picker-test.cpp}::fun().

+ Here is the call graph for this function:
+ Inheritance diagram for VariadicArgumentPicker_test:
+ Collaboration diagram for VariadicArgumentPicker_test:

The documentation for this class was generated from the following file: