I'm struggling to make this code work
template <typename T, typename U = int, auto... Params>
class Foo {};
int main()
{
auto foo1 = Foo<int, int, 1, 2, 3>{};
auto foo2 = Foo<int, 1, 2, 3>{}; // I want it to compile
}
It looks like I need some hack. I tried partial specialization, but it doesn't work either
template <typename T, typename U, auto... Params>
class Foo {};
template <typename T, auto... Params>
class Foo<T, int, Params...> {};
int main()
{
auto foo1 = Foo<int, int, 1, 2, 3>{};
auto foo2 = Foo<int, 1, 2, 3>{}; // I want it to compile
}
I can't find anything closely related to this, help pls :)
Foo.Foo<list<int, int>, 1, 2, 3>.struct A {} A;. This means thatAcan be a type when a type is expected by the parser, but it can also be a value when a value is expected by the parser. So it's the calling code that must resolve whether something is a type or a value. In your case, this is undecided.