Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-10 00:34:57


Zach Laine wrote:
> Naively, I would have reduced them to:
>
> struct unordered_tag {};
>
> template<class Hash, class Flavor, class T> constexpr void hash_append(
> Hash& h, Flavor const& f, T const& v );
>
> template<class Hash, class Flavor, class It> constexpr void hash_append(
> Hash& h, Flavor const& f, It first, It last );
>
> template<class Hash, class Flavor, class It> constexpr void hash_append(
> Hash& h, Flavor const& f, It first, It last, unordered_tag );
>
> Is there a reason that could not work?

There is, yes. Naming everything hash_append doesn't play well with
making hash_append variadic, as has already been suggested a few times.

Once you have that, the above overload set becomes a nice trap because

  hash_append( h, f, "foo", "bar" );

calls the iterator overload.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk