Following some of the solutions provided here How can I have multiple parameter packs in a variadic template?, I'm hoping to apply multiple parameter packs to a classes and use CTAD to make the class more usable.
Here is what I came up with (on Coliru), but this gives:
error: class template argument deduction failed
Here is the code I tried:
// A template to hold a parameter pack
template < typename... >
struct Typelist {};
// Declaration of a template
template< typename TypeListOne
, typename TypeListTwo
>
struct Foo;
// A template to hold a parameter pack
template <typename... Args1, typename... Args2>
struct Foo< Typelist < Args1... >
, Typelist < Args2... >
>{
template <typename... Args>
struct Bar1{
Bar1(Args... myArgs) {
_t = std::make_tuple(myArgs...);
}
std::tuple<Args...> _t;
};
template <typename... Args>
struct Bar2{
Bar2(Args... myArgs) {
_t = std::make_tuple(myArgs...);
}
std::tuple<Args...> _t;
};
Bar1<Args1...> _b1;
Bar2<Args2...> _b2;
Foo(Bar1<Args1...>& b1, Bar2<Args2...>& b2) {
_b1 = b1;
_b2 = b2;
}
};
int main()
{
Foo{Foo::Bar1(1, 2.0, 3), Foo::Bar2(100, 23.4, 45)};
return 0;
}