Victor said:
desktop said:
[..]
I am currently reading Bjarne Stroustrup and Accelerated C++. In
Bjarne I can only find half a page about sets in section 17.4.3 that
corresponds to what is found in the C++ Standard text.
Get a hold of a copy of "The C++ Standard Library" by Josuttis.
Have that also found something useful in section 22.4.2, thanks for the
reference!
"The set should have defined the less operator"? Either you are
misquoting or you've misunderstood. The set does not have to define
the less operator.
On page 505 in the C++ Standard the operators for set are declared:
template <class Key, class Compare, class Allocator>
bool operator==(const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
template <class Key, class Compare, class Allocator>
bool operator< (const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
template <class Key, class Compare, class Allocator>
bool operator!=(const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
template <class Key, class Compare, class Allocator>
bool operator> (const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
template <class Key, class Compare, class Allocator>
bool operator>=(const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
template <class Key, class Compare, class Allocator>
bool operator<=(const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y);
So I guess that the "less operator" should be defined for set. Again
this has nothing to do with object being inserted into a set. But I will
follow your advice an investigate the std::less further and also look
into section 22.4.2 in Josuttis.
Don't read the interface. Read the implementation. "Use the Source,
Luke!"
Thats another think I have some trouble finding, see my post:
"Source files for buildt-in containers in std?"