| Re: Class template specialization with template parameter |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.c++ · Group Profile
Author: Greg HerlihyGreg Herlihy Date: May 14, 2008 13:20
On May 14, 12:51Â pm, flopbucket hotmail.com> wrote:
> Hi,
>
> First, thanks for the reply.
>
>>> Foo uses the normal template, but Foo > for any
>>> types of T1 and T2 uses the specifalization?
>
>> Not sure what you're asking here.
>
> What I was trying to say was that if I declare:
>
> Foo myFoo();
I believe that you mean to declare an object (and not a function):
Foo myFoo;
> The instantiation will be for the normal/not-specialized template.
Yes.
> But if I declare:
>
> Foo > myFoo2();
Again, I believe that you want:
Foo > myFoo2;
> it will use the specialization... and that regardless of the types
> used for std::map (in this case, int and std::string), any
> "Foo > Â myFooExample()" Â will always
> instantiate the specialization.
The answer depends on how many template parameters "std::map"
requires. The usual number is two - the two specified by the C++
Standard. An implementation however is allowed to require additional
temmplate type parameters for a std::map. So, assuming that std::map
requires only two type parameters, then the answer is "yes".
Greg
|