Marking the function as const promises that it will not change the object. So it can be used on const objects.
The STL almost certainly takes the arguments as const, because that is the smart thing to do.
It shouldn't hurt you to define operator<
as const because I cannot imagine having a less-than operator that changes the object. That would just be silly.
If you want to know exactly where here is some code copied out of libstdc++ bits/stl_algo.h on a Fedora 20 machine:
/// This is a helper function...
template<typename _RandomAccessIterator, typename _Tp, typename _Compare>
_RandomAccessIterator
__unguarded_partition(_RandomAccessIterator __first,
_RandomAccessIterator __last,
const _Tp& __pivot, _Compare __comp)
const _Tp& __pivot
, right there.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…