1

I am learning about C++ templates from C++ Primer 5th edition. For example, i learnt that we could do the following:

template<typename T>
struct Custom 
{
    
};

template<>
struct Custom<int> 
{
  int a = 0;  
};

Then i learnt that C++11 also added a feature of alias templates. So i tried the same with them as shown below:

template<typename T>
using var = std::stack<T>;

template<>
using var<double> = double;

But the above shown snippet doesn't work. What is the problem here, why doesn't the 2nd snippet work.

Julian
  • 53
  • 6

1 Answers1

1

The problem is that we cannot specialize an alias templates.

From temp.decls 17.5.3:

Because an alias-declaration cannot declare a template-id, it is not possible to partially or explicitly specialize an alias template.

Jason
  • 36,170
  • 5
  • 26
  • 60