https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68409

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Adrian Wielgosik from comment #2)
> Your operator< doesn't seem to satisfy strict weak ordering. Once I rewrote
> it to a basic but safer version:
> 
> bool operator< (const chave& lhs, const chave& rhs) {
>     if(lhs.numeros_ord != rhs.numeros_ord)
>         return lhs.numeros_ord < rhs.numeros_ord;
>     return lhs.estrelas_ord < rhs.estrelas_ord;
> }

This is a correct implementation.


Since C++11 is being used it can also be done like this:

bool operator< (const chave& lhs, const chave& rhs) {
    return std::tie(lhs.numeros_ord, lhs.esterlas_ord)
         < std::tie(rhs.numeros_ord, rhs.esterlas_ord);
}

Reply via email to