S
Samee Zahur
Why aren't we allowed to do partial specializations like these on
numeric template parameters? That would have allowed us to do all
kinds of interesting stuffs like loops of variable nesting (bad
practice though - I Know) and lots of other things!g++ even knows
that it is a partial specialization I am aiming for ... but it
just won't allow it!
//-----------------------------------------------------------------
template <unsigned X,unsigned Y> unsigned pow(){return pow<X,Y-1>();}
template <unsigned X> unsigned pow<X,0>(){return 1;} //ERROR!!
const unsigned var2=pow<2,5>();
//-----------------------------------------------------------------
Even funnier, complete specializations of these type are very legal!
For example,
//-----------------------------------------------------------------
template <unsigned X> unsigned powof3(){return 3*powof3<X-1>();}
template <> unsigned powof3<0>(){return 1;}
const unsigned var=powof3<4>();
//-----------------------------------------------------------------
and no one complains! but why is there a difference here?
Samee
numeric template parameters? That would have allowed us to do all
kinds of interesting stuffs like loops of variable nesting (bad
practice though - I Know) and lots of other things!g++ even knows
that it is a partial specialization I am aiming for ... but it
just won't allow it!
//-----------------------------------------------------------------
template <unsigned X,unsigned Y> unsigned pow(){return pow<X,Y-1>();}
template <unsigned X> unsigned pow<X,0>(){return 1;} //ERROR!!
const unsigned var2=pow<2,5>();
//-----------------------------------------------------------------
Even funnier, complete specializations of these type are very legal!
For example,
//-----------------------------------------------------------------
template <unsigned X> unsigned powof3(){return 3*powof3<X-1>();}
template <> unsigned powof3<0>(){return 1;}
const unsigned var=powof3<4>();
//-----------------------------------------------------------------
and no one complains! but why is there a difference here?
Samee