Re: Class requirements to be used in a STL container?
On May 27, 7:55 pm, Neelesh <neelesh.bo...@gmail.com> wrote:
On May 27, 3:14 pm, Rui Maciel <rui.mac...@gmail.com> wrote:
What requirements should a class fulfil in order to be able
to be used with a STL container class?
Copy constructible and Assignable are the two requirements for
all container classes in general. Further, if the container is
associative container, then the members (for set) and keys
(for map) must have strict weak ordering. The comparsion
operator can be explicitly provided. If not, it defaults to
operator<
Strictly speaking, the comparison operator defaults to
std::less<T> (for type T). Which in turn defaults to operator<
for non-pointer types, and to something which provides the
necessary ordering for pointer types. (Often operator<: while
comparing pointers not pointing into the same object is
undefined in the standard, many implementations do define it.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34