I have a class template S1
with two integer arguments:
template <int A, int B> struct S1 { };
I have another class template S2
with one integer argument. In S2
there is a type template My_S1
that specializes S1
. It works fine when S1
is instantiated through a specialization of S2
in main
:
template<int A> struct S2 {
template<int B>
using My_S1 = S1<A, B>;
};
int main(int argc, char *argv[]) {
using S1_a = S2<0>::My_S1<0>;
}
But if I try to do this in a third class template as below, I get an error when compiling. Full code:
template<int A, int B>
struct S1 { } ;
template<int A>
struct S2 {
template<int B>
using My_S1 = S1<A, B>;
};
template<int A, int B>
struct S3 {
using My_S1 = typename S2<A>::My_S1<B>; // I get an error on this line
};
int main(int argc, char * argv[]) {
using S1_a = S1<0, 0>; // works fine, of course
using S1_b = S2<0>::My_S1<0>; // works fine
using S1_c = S3<2,1>::My_S1; // ?
return 0;
}
The error I get is the following:
error: expected ‘;’ before ‘<’ token
using My_S1 = typename S2<A>::My_S1<B>;
^
error: expected unqualified-id before ‘<’ token