Why are the STL functors themselves templated and not their function call operator?

Viewed 722

The STL functors are implemented like this:

template<class T>
struct less{
  bool operator()(T const& lhs, T const& rhs){
    return lhs < rhs;
  }
};

This makes us mention the (possibly long) type everytime we create such a functor. Why are they not implemented like shown below? Any reasons?

struct less{
  template<class T>
  bool operator()(T const& lhs, T const& rhs){
    return lhs < rhs;
  }
};

That would make them usable without any mentioning of (possibly long) types.

2 Answers
Related