Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial specialization in c++ template : template parameter not deducible

Tags:

The below code works fine :

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

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

But the below code shows error as:

Error : template parameters not deducible 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 behaviour ?

like image 640
Achyuta Aich Avatar asked Aug 17 '17 16:08

Achyuta Aich


1 Answers

I believe you are just missing the right syntax for the partial specialization:

template<typename T, int n> 
 class Fib {

 };

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

 };

The first parameter on the template is type, while the second is just a constant value.

like image 140
kEst86 Avatar answered Oct 11 '22 16:10

kEst86