5

For example

struct Option_1
{
    template<class T> using Vector = std::vector<T>;
};

I can do

typename Option_1::Vector<int> v;

But I prefer the following

Vector<Option_1, int> v;

or similars without the word "typename". I define an alias

template<class Option, class T> using Vector= typename Option::Vector<T>;

but failed with unrecognizable template declaration/definition. How to fix it?

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
user1899020
  • 13,167
  • 21
  • 79
  • 154

1 Answers1

4

You should use the keyword template for the dependent template name Option::Vector, i.e.

template<class Option, class T> using Vector = typename Option::template Vector<T>;
//                                                              ~~~~~~~~

LIVE

songyuanyao
  • 169,198
  • 16
  • 310
  • 405