template parameters not deducible in partial specialization

Jonathan Wakely jwakely.gcc@gmail.com
Fri Nov 18 18:18:00 GMT 2016


On 18 November 2016 at 14:20, Leseratte wrote:
> Hello,
>
> i have a base template class like this:
>
> template<uint8_t num, typename T> class A { ... }
>
> and I want to place the implementation differences in specialized templates
> like this:
>
> template<uint8_t num, typename T> class A<0, uint8_t> { ... }
> template<uint8_t num, typename T> class A<1, uint16_t> { ... }
> template<uint8_t num, typename T> class A<2, uint8_t> { ... }
>
> I use compiler from trunk compiled for target avr and I get the error:
>
> sample.h:291:15: error: template parameters not deducible in partial
> specialization:
>          class A<0, uint8_t>
>                ^~~~~~~~~~~~~~~~~
> sample.h:291:15: note:         'num'
> sample.h:291:15: note:         'T'
>
>
> I read that template with different integer values should work, so what's my
> fault?

Your syntax is wrong (so it's not a GCC problem, and you should take
any further questions to a general C++ forum).

When you specialize a template argument it doesn't appear in the
parameter list, i.e.

template<> class A<0, uint8_t> { ... }



More information about the Gcc-help mailing list