|
Prev: Operator!= injection (from std::rel_ops)
Next: string::find() behaviour searching for an empty string
From: Jochen Eisinger on 16 Jan 2008 18:11 Hi, if I'm not mistaken, the compare parameter of the std::set template has to fulfill the "strict weak ordering" requirement. In contrast to a "total ordering", two objects might just not be comparable by a strict weak ordering, i.e. neither x < y nor y < x although x != y. So using a "strict weak ordering", std::set can't determine whether an element is already in the set or not, just whether an element of the same class wrt. the compare parameter is already in the set. In fact, if you instantiate std::set as implemented with gcc with a not-total ordering, you can't insert two different elements, which cannot be ordered. So my question is: should the compare object actually fulfill a total ordering requirement, or should a set be seen as a container containing one representant per equivalence class? regards -- jochen -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |