you have to use typename keyword to make it work:
static void Foo(T t, typename T::B b) {}
^
and enum B
has to be public.
typename
keyword it is used for specifying that a dependent name in a template definition or declaration is a type. It is synonym for a class
in template parameters.
C++ standard states:
A name used in a template declaration or definition and that is
dependent on a template-parameter is assumed not to name a type unless
the applicable name lookup finds a type name or the name is qualified
by the keyword typename.
so unless you state explicitly typename T::B b
, compiler will assume T::B b
is value type not a type name.
To summarise:
class A {
public:
enum B {enum1, enum2};
};
template<typename T>
static void Foo(T t, typename T::B b) {}
int main()
{
A a;
Foo(a, a::enum1);
}
typename