Consider this simple, but complete example:
#include <iostream>
enum class Foo
{
A,
B
};
template <Foo F>
struct X{};
template <Foo F>
constexpr Foo deduce_foo(X<F>&& arg)
{
return F;
}
int main()
{
if ( deduce_foo(X<Foo::B>{}) == Foo::A )
std::cout << "A";
else
std::cout << "B";
std::cout << std::endl;
}
which deduces the enum class
correctly (function deduce_foo(...)
).
Now, I want to make it more generic, substituting X by a template T, i.e:
template <Foo F, typename T>
constexpr Foo deduce_foo(T<F>&& arg) { ... }
But compiler (g++ 7.3.0) gives me this error:
error: ‘T’ is not a template constexpr Foo deduce_foo(X&& arg)
What Im doing wrong?