![]() |
Prusa Slicer 2.6.0
|
Helper class to be able to loop over a parameter pack's elements. More...
#include <src/libnest2d/include/libnest2d/utils/metaloop.hpp>
Classes | |
| class | _MetaLoop |
| class | _MetaLoop< Int< 0 >, Args... > |
| class | _MetaLoop< Int< N >, Args... > |
| class | MapFn |
Static Public Member Functions | |
| template<class... Args, class Fn > | |
| static void | apply (Fn &&fn, Args &&...args) |
| The final usable function template. | |
| template<class... Args, class Fn > | |
| static void | apply (Fn &&fn, tuple< Args... > &&tup) |
| The version of apply with a tuple rvalue reference. | |
| template<class... Args, class Fn > | |
| static void | apply (Fn &&fn, tuple< Args... > &tup) |
| The version of apply with a tuple lvalue reference. | |
| template<class... Args, class Fn > | |
| static void | apply (Fn &&fn, const tuple< Args... > &tup) |
| The version of apply with a tuple const reference. | |
| template<class Fn , class Tup , std::size_t... Is> | |
| static auto | callFunWithTuple (Fn &&fn, Tup &&tup, index_sequence< Is... >) -> decltype(fn(std::get< Is >(tup)...)) |
Private Types | |
| template<int N> | |
| using | Int = std::integral_constant< int, N > |
| template<class... Args> | |
| using | MetaLoop = _MetaLoop< Int< sizeof...(Args) -1 >, Args... > |
Helper class to be able to loop over a parameter pack's elements.
| class libnest2d::opt::metaloop::_MetaLoop |
|
private |
|
private |
|
inlinestatic |
The final usable function template.
This is similar to what varags was on C but in compile time C++11. You can call: apply(<the mapping function>, <arbitrary number of arguments of any type>); For example:
struct mapfunc {
template<class T> void operator()(int N, T&& element) {
std::cout << "The value of the parameter "<< N <<": "
<< element << std::endl;
}
};
apply(mapfunc(), 'a', 10, 151.545);
C++14: apply([](int N, auto&& element){ std::cout << "The value of the parameter "<< N <<": " << element << std::endl; }, 'a', 10, 151.545);
This yields the output: The value of the parameter 0: a The value of the parameter 1: 10 The value of the parameter 2: 151.545
As an addition, the function can be called with a tuple as the second parameter holding the arguments instead of a parameter pack.
Referenced by libnest2d::opt::NloptOptimizer::optfunc(), and libnest2d::opt::NloptOptimizer::optimize().
Here is the caller graph for this function:
|
inlinestatic |
The version of apply with a tuple const reference.
|
inlinestatic |
The version of apply with a tuple rvalue reference.
|
inlinestatic |
The version of apply with a tuple lvalue reference.
|
inlinestatic |
Call a function with its arguments encapsualted in a tuple.
Referenced by libnest2d::opt::NloptOptimizer::optfunc().
Here is the caller graph for this function: