简体   繁体   中英

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

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM