1

Why does the following code not work (using VS2013)?

class Test1
{
public:
  template<typename T>
  using my_type = T;
};

template<typename T, typename V>
class My : public T
{
public:
  using t_type = T;
  using my_type2 = t_type::my_type<V>;
};

int main()
{
  const My<Test1, double>::my_type2 x = 5.5;

  return 0;
}

Test1::my_type would have a more complex type. My would be a policy based class where Test1 would be one of the policies. my_type2 should become a specific type based on the policy. And Test1 can't be a template directly taking the type of V. Thanks.

Piotr Skotnicki
  • 46,953
  • 7
  • 118
  • 160
blackmav
  • 13
  • 3

1 Answers1

2

Welcome to a dark corner of C++

Change this

using my_type2 = t_type::my_type<V>;

to this:

using my_type2 =  typename t_type::template my_type<V>;
bolov
  • 72,283
  • 15
  • 145
  • 224
  • Thanks a lot, I almost had it, and I knew that it may be in this direction, but I put in typename instead of template after t_type::. And sorry for the duplicate, I seem not to have search with the right arguments. – blackmav Apr 20 '15 at 12:40
  • gcc actually tells in the error message: typename needed and then template needed – bolov Apr 20 '15 at 12:44