C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Q: invariant for unordered_set and unordered_map "hash" and "comp" argument

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 28 Nov 2026 09:03:36 -0800
On Saturday, 28 November 2026 06:11:01 Pacific Standard Time Aleksandr
Povaliaev via Std-Proposals wrote:
> I think that we can introduce a compile-time warning: if a Key class has a
> comparison operator defined, it should be used by default - otherwise a
> warning is shown.

Isn't the comparison operator what the default comparison predicate uses? So
what's *wrong* with the current way?

Do you want to warn people about overriding the comparison predicate? How do
you know it is incorrect? Should it warn when the hasher is also replaced?
Should it warn if you replace the hasher but not the comparison?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-11-28 17:03:47