c++ syntax error when specializing nested template of a template parameter

29 Views Asked by At

This is what I'm trying to do:

template<typename T, int I>
class A {
public:
    using CA = T::C<I>;
};

class B {
public:
    template<int I>
    struct C {};
};

int main()
{
    A<B, 1> a;
    return 0;
};

However, inexplicably (to me), this comes up as a syntax error - "missing ';' before '<' at the "using UA =" line. Have tried quite a few variations but can't figure out what's missing. Thanks

1

There are 1 best solutions below

0
lequinne On

Corrected syntax:

using UA = T::template U;

Looks like this was actually answered previously in great detail at Where and why do I have to put the "template" and "typename" keywords?

Thanks all.