babel92
babel92

Reputation: 777

Name alias for a specialized template in C++ 11

I'm doing this:

template<typename Elem, int D1=1, int D2=1, int D3=1> class matrix;

And have a specialization:

template<typename Elem> class matrix<Elem, 1, 1, 1>;

Now, I want to get an alias of the specialized template, like this:

template<typename Elem> class scalar;

Since it has a template parameter Elem, typedef seems don't work. And I don't want to derive the new scalar class from matrix < Elem,1,1,1>... Can I achieve this? Many thanks.

Upvotes: 1

Views: 90

Answers (1)

David G
David G

Reputation: 96810

You can use a using alias:

template<class Elem>
using scalar = matrix<Elem, 1, 1, 1>;

Upvotes: 2

Related Questions