According to 20.8.5 §1, std::less
is a class template with a member function:
template<typename T>
struct less
{
bool operator()(const T& x, const T& y) const;
// ...
};
Which means I have to mention the type when I instantiate the template, for example std::less<int>
. Why isn't std::less
a normal class with a member function template instead?
struct less
{
template<typename T, typename U>
bool operator()(const T& x, const U& y) const;
// ...
};
Then I could simply pass std::less
to an algorithm without the type argument, which can get hairy.
Is this just for historic reasons, because early compilers (supposedly) did not support member function templates very well (or maybe even at all), or is there something more profound to it?