I am playing with variadic macro and template. Is there any simple way to achieve the following?
It's like std::make_tuple. How to implement make_my_class? I saw I probably need "std::decay" but I don't quite understand that. Thanks a lot in advance.
template <typename... Args>
class my_class
{
public:
my_class(Args... args)
: items_(args...)
{
}
private:
std::tuple<Args...> items_;
};
// How to fix this line?
#define CREATE_MY_CLASS(var_name, args...) my_class<decltype(args...)> var_name(args...);
// Usage:
// CREATE_MY_CLASS(xyz, 1, 2, 3)
// Target:
// my_class<decltype(1), decltype(2), decltype(3)> xyz(1, 2, 3);