I believe that you mean to declare an object (and not a function):
Again, I believe that you want:
Foo<std::map<int, std::string> > myFoo2;
The answer depends on how many template parameters "std::map"
requires. The usual number is two - the two specified by the
C++ Standard.
The usual number is four, since that's what the C++ standard
requires. He has defined a partial specialization for Foo<
std::map< T, U, std::less<T>, std::allocator< std:
air< T
const, U > >. If he instantiates Foo with a type which
corresponds to this, the partial specialization will be used.
Otherwise, the non-specialized version will be used. Thus, with
std::map< int, std::string > (or std::map< int, std::string,
std::less< int > >), he'll get the partial specialization, but
he'll said:
An implementation however is allowed to require additional
temmplate type parameters for a std::map.
But only if they follow the required four, and have default
values. So as long as you don't use them, his code should work.
So, assuming that std::map requires only two type parameters,
then the answer is "yes".
Assuming that the implementation of std::map is conform, his
partial specialization will be used for all std::map
instantiations which use std::less<Key> as the comparator, and
std::allocator< std:
air< Key const, T > > as the allocator.
(Using something other than the default allocator is fairly
rare, but it's quite frequent to find map's with other than the
default comparison function. In his case, I would definitly add
that to the arguments of the partial specialization. And it's
not that difficult to add the allocator either:
template< typename Key, typename Value,
typename Cmp, typename Alloc >
class Foo< std::map< Key, Value, Cmp, Alloc > >
{
// ...
} ;
This should work for all instanciations of std::map.