View Single Post
Old May 30th, 2006, 9:48 PM   #3
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,253
Rep Power: 5 grumpy will become famous soon enough
The reason comes down to how templates are instantiated. In essence, a template can only be instantiated for types that have external linkage (in your context, they cannot be anonymous). If you want to avoid cluttering the global namespace with your algorithms, place them in a namespace of their own.

In this example, as you're using <algorithm> anyway, why not use this?
   return *( std::max_element(s.begin(), s.end(), std::less<int>()) );
grumpy is offline   Reply With Quote