0

What's wrong with the following usage of a template using declaration?

template <typename T1, typename T2> struct A {
    template <typename AnotherT1>
    using MyTemplate = A<AnotherT1, T2>;
};

template<class SomeA> struct B {
    using MyType = typename SomeA::MyTemplate<double>;
};

int main() {
    B<A<int, int>> b; (void)b;
}

gcc 4.8.2 complains:

temp.cpp:17:46: error: expected ‘;’ before ‘<’ token
     using MyType = typename SomeA::MyTemplate<double>;
                                              ^
temp.cpp:17:46: error: expected unqualified-id before ‘<’ token
temp.cpp: In instantiation of ‘struct B<A<int, int> >’:
temp.cpp:21:20:   required from here
temp.cpp:17:46: error: ‘typename A<int, int>::MyTemplate’ names ‘template<class AnotherT1> using MyTemplate = struct A<AnotherT1, int>’, which is not a type
AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68

1 Answers1

0

Reference this page. https://msdn.microsoft.com/en-us/library/0afb82ta.aspx

Modify like below:

using MyType = typename SomeA::template MyTemplate<double>;
Piotr Skotnicki
  • 46,953
  • 7
  • 118
  • 160