Trying to make below code to use the etl
library.ETL
#include <functional>
#include <tuple>
template < typename Function, typename...Args >
class Class {
private:
Function function_; // ---> using etl::delegate
std::tuple < Args... > args; // ?????
public:
Class(Function _function, Args..._args):
function_ {std::forward < Function > (_function }, // ----> using etl::forward
args {std::forward < Args > (_args)... }
{}
auto function()
{
return std::apply(function_,args); // ????
}
};
std::tuple
,std::make_tuple
To store parameters -->etl::variant
( etl::variant )
Most of the examples have an std::make_tuple
which I couldn't find an etl
equvialnet.
Is there any other option beside using etl::variant?
etl::variant<Args...> args;
public:
Class(Function _function, Args... _args) :
function_ { etl::forward<Function>(_function) } ,
args{/*std::make_tuple*/
< etl::forward < Args > (_args)... >
} // is make_tuple a must??
{}
std::apply
To unpack and invoke. I used code another implementaion, using an index sequencer. But replacingstd::tuple
withetl::variant
throws an error.;
template <typename... Args, int... Is>
void func(etl::variant < Args... > & tup, helper::index < Is... > ) {
f(std::get < Is > (tup)...);
}
template < typename...Args, int...Is >
void func(etl::variant < Args... > & tup, helper::index < Is... > ) {
f(std::get < Is > (tup)...);
}
template < typename...Args >
void func(etl::variant < Args... > & tup) {
func(tup, helper::gen_seq < sizeof...(Args) > {}); // this shows an error and won't run.
}