Partial specialization in C ++ template: template parameter is not output

The code below is working fine:

template<typename T, int n> 
class Fib {};

template<typename T,int n>
class Fib<T*,n> {}; 

But the code below shows the error as:

Error: template parameters are not displayed in partial specialization:

 template<typename T, int n> 
 class Fib {};

 template<typename T,int n>
 class Fib<T*,0> {};

Can you explain the reason for this behavior?

+4
source share
1 answer

I believe that you simply lack the correct syntax for partial specialization:

template<typename T, int n> 
 class Fib {

 };

 template<typename T>
 class Fib<T*,0> {

 };

The first parameter in the template is a type, and the second is only a constant value.

+4
source

Source: https://habr.com/ru/post/1683915/


All Articles