I have some trouble with a piece of C++ code.
First, if I do this, it works quite well :
struct A
{
using my_type1 = double;
using my_type2 = int;
};
struct B
{
using size_type = A::my_type2;
};
However, I want to be able to choose my_type1, so I went the template way :
template <typename T>
struct A
{
using my_type1 = T;
using my_type2 = int;
};
template <typename T>
struct B
{
using size_type = A<T>::my_type2;
};
Here, gcc fails with : "expected type specifier" on the line
using size_type = A<T>::my_type2;
I could just put my_type2 in template too but this is a type that shouldn't change much.
So why doesn't my method work ? Thanks!
You have to add typename
:
using size_type = typename A<T>::my_type2;