0

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

lequinne
  • 118
  • 8
  • 2
    Does [more complete diagnostic information](https://godbolt.org/z/j6TMa5sYj) help any? – user4581301 Apr 13 '23 at 19:07
  • 1
    [Where and why do I have to put the "template" and "typename" keywords?](https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – Drew Dormann Apr 13 '23 at 19:10
  • @user4581301 Thanks for the resource. using UA = T::template U; did the trick. Knew it had to be something along those lines, but somehow couldn't figure it out. – lequinne Apr 13 '23 at 19:15

1 Answers1

0

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.

lequinne
  • 118
  • 8