TT (Tom Tempelaere) wrote in
news:_jyMb.8737$:
> "Rob Williscroft" <> wrote in message
> news:Xns946E8EBB3F680ukcoREMOVEfreenetrtw@195.129. 110.200...
>> TT (Tom Tempelaere) wrote in
>> news:ixxMb.8679$:
>>
[snip]
>> Add a default here if that is what you want.
>>
>> template<typename T, size_t n = 3 >
>
> That is _not_ what I want to do.
Actually when you combine the default with the specialization, it
probably is, but you didn't say what you wanted to do.
>
>> > template<typename T, size_t n>
>> > struct B;
>> >
>> > template<typename T>
>> > struct B<T,2> {};
>> >
>> > int main()
>> > {
>> > A<int,2> a;
>> > B<float> b; // ***
>> > }
>> >
>> > What am I doing wrong?
>>
>> Your declaring a default, so you can't use a default.
>
Whoops missed a *not* in the above, It should have been:
Your not declaring a default, so you can't use a default.
> I am not declaring a default, I'm partially specializing a template
> class. That has nothing to do with defaults!
Yes you are, but then you try to use the class as if you had
given it a default for its second paramiter.
>
>> Either add a sutible default or change line *** to
>>
>> B< float, 3 > b;
>
> That would make partial specialization totally unusable!
You seem to be confused about what specialization does.
There can be only one class or class-template named B, if its
a class-template say B< typename, size_t > then it takes 2
arguments, specialization *isn't* overloading.
From your code above:
B< int, 1 > b1; // will instantiate the the unspecialized template.
B< int, 2 > b2; // will instantiate the specialization.
>
> Do you actually know what partial specialization of a template class
> is?

Yes *I* do.
>
>> HTH.
>>
Rob.
--
http://www.victim-prime.dsl.pipex.com/