C++ Logo


Advanced search

Re: std::hash

From: Chris Ryan <chrisr98008_at_[hidden]>
Date: Fri, 24 Mar 2023 15:35:10 -0700
`std::vector<bool>` is a specialized implementation that is done
differently from the other vectors & types because of the need to do the
underlying bit packing.
Other types come out in the wash on their own.


On Fri, Mar 24, 2023 at 2:14 PM Marcin Jaczewski via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> I recently looked at `std::unordered_map` and noticed a bit of a
> bizarre handling of `std::hash` in the standard library.
> Why of all types that could be useful, does the standard define only
> `std::vector<bool>`?
> Where `std::tuple` or other vectors are left unusable.
> What is the reason for standard not defining
> `std::hash<std::vector<T>>` if `T` has a hash?
> And why is `bool` the only exception there? What was the motivation for
> this?
> https://eel.is/c++draft/vector.bool#pspc-7
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2023-03-24 22:35:23