Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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

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

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.
 

Member Function Documentation

◆ run()

virtual void run ( Arg  )
inlineprivatevirtual

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

References VariadicArgumentPicker_test::check_pickArg(), VariadicArgumentPicker_test::check_pickInit(), VariadicArgumentPicker_test::check_reorderedArguments(), and VariadicArgumentPicker_test::verify_fixture().

+ Here is the call graph for this function:

◆ verify_fixture()

void verify_fixture ( )
inlineprivate

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

Referenced by VariadicArgumentPicker_test::run().

+ Here is the caller graph for this function:

◆ check_pickArg()

void check_pickArg ( )
inlineprivate

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

Referenced by VariadicArgumentPicker_test::run().

+ Here is the caller graph for this function:

◆ check_pickInit()

void check_pickInit ( )
inlineprivate

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

References lib::meta::typeStr().

Referenced by VariadicArgumentPicker_test::run().

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

◆ call_with_reversed_arguments()

template<class... ARGS, size_t... idx>
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.

Referenced by VariadicArgumentPicker_test::check_reorderedArguments().

+ Here is the caller 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 VariadicArgumentPicker_test::call_with_reversed_arguments().

Referenced by VariadicArgumentPicker_test::run().

+ Here is the call graph for this function:
+ Here is the caller 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: