Date: Sat, 28 Nov 2026 22:34:35 +0300
On 28 Nov 2026 21:14, Aleksandr Povaliaev via Std-Proposals wrote:
> I don't like the idea of having two different comparison operators for
> the same Key class.
> This is erroneous flexibility - I can't imagine a design pattern which
> somehow can explain "having two different comparison operators" - it
> only adds a mess.
No, having multiple comparison predicates can be very much sensible, as
there can be multiple ways in which two objects are considered
equivalent. For example, your unordered_set may use a subset of data
comprising the element for hashing and equivalence predicate, and you
may also have an operator== that compares the entire objects.
> I don't like the idea of having two different comparison operators for
> the same Key class.
> This is erroneous flexibility - I can't imagine a design pattern which
> somehow can explain "having two different comparison operators" - it
> only adds a mess.
No, having multiple comparison predicates can be very much sensible, as
there can be multiple ways in which two objects are considered
equivalent. For example, your unordered_set may use a subset of data
comprising the element for hashing and equivalence predicate, and you
may also have an operator== that compares the entire objects.
Received on 2026-11-28 19:34:40
