Re: erase() woes on std::multiset with custom Compare

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Kanze

    Re: erase() woes on std::multiset with custom Compare

    On Nov 11, 10:12 am, newbar...@gmail .com wrote:
    The secondary comparison of addresses and reverting to a
    std::set will do the trick thanks.
    I certainly don't want to invoke undefined behaviour. Surely
    it's fine as I'm comparing pointers to the same base?
    As Jerry pointed out, it's not undefined, just unspecified. To
    the point where (theoretically) , given two pointers a and b, a<b
    might be true one time, and false the next time you try it. In
    practice, of course, there are (or at least have been) a lot of
    cases where !(a < b) && !(b < a), even though a and b point to
    different objects (and a != b); such an ordering will NOT work
    with std::set.

    As Jerry also pointed out, the standard requires std::less to
    work. Use it instead.

    --
    James Kanze (GABI Software) email:james.kan ze@gmail.com
    Conseils en informatique orientée objet/
    Beratung in objektorientier ter Datenverarbeitu ng
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Working...