vk02720 said:
How does the STL "set" class ensure uniqueness ? Does the contained
type need to implement a certain method or override a certain operator
( != or < ) ?
By default std::set uses std::less to sort its items which in turn
relies on less than comparisons for generic types. So if instances of
the std::set's type can be compared to each other with the less-than
operator then std::set fully supports that type.
An interesting question in the case of a type that does not support
less-than comparisons is whether the client must overload the <
operator to be compatible with std::less - or whether the client may
specialize std::less for a particular type.
Ordinarily the std namespace is off limits to client code, but it is
permissible to specialize a std namespace template as long as two
conditions are met: first, the specialized type must be a
client-defined type and second, the specialized template must meet all
of the requirements that apply to the general template. [§17.4.3.1]
Greg