What's wrong with using a function template?
template <typename ... Args>
my_class<Args...> get_my_class(Args&&...args)
{
return my_class<Args...>(std::forward<Args>(args)...);
}
auto x = get_my_class(1,2,3,4,5,6);
To use the variadic arguments of a macro requires __VA_ARGS__
and I don't know how or if you can pass that to decltype()
since you need to do something that will amount to decltype(args)...
to get a list of types of args
. The function template bypasses all of that with its implicit template deduction and the auto
keyword means you don't have to know what types are being passed to my_class
to declare a variable of the appropriate type.