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

--- Comment #15 from frs.dumont at gmail dot com ---
On 05/11/2024 18:18, redi at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115285
>
> --- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> We're assuming that an iterator's reference type can be converted to the
> key_type. This doesn't compile on trunk:
>
> #include <unordered_set>
>
> struct K {
>    explicit K(int) noexcept { }
>    bool operator==(const K&) const { return true; }
> };
>
> template<> struct std::hash<K> {
>    auto operator()(const K&) const { return 0ul; }
> };
>
> int i[1];
> std::unordered_set<K> s(i, i+1);
>
>
> This fails for similar reasons:
>
> #include <unordered_map>
>
> struct K {
>    explicit K(int) noexcept { }
>    bool operator==(const K&) const { return true; }
> };

It's surprising that we need to handle this use case. The user wants K 
is to be explicitly built from int but then insert ints, weird. Are 
other Standard library handling this ?

You know C++ Standard much better than I do though.

Reply via email to