Boost logo

Boost :

Subject: Re: [boost] [functional] How to avoid a dependency on functional?
From: Peter Dimov (lists_at_[hidden])
Date: 2015-01-09 15:17:30

Beman Dawes wrote:
> Filesystem has a dependency on <boost/functional/hash_fwd.hpp> in order to
> supply this:
> inline std::size_t hash_value(const path& x)
> {
> std::size_t seed = 0;
> for(const path::value_type* it = x.c_str(); *it; ++it)
> hash_combine(seed, *it == '/' ? L'\\' : *it);
> return seed;
> # else // BOOST_POSIX_API
> return hash_range(x.native().begin(), x.native().end());
> # endif
> }
> Is there any recommended way to avoid the functional dependency?

In this specific case, I would forward-declare hash_combine and hash_range.
I already submitted a pull request against array along the same lines, which
Marshall graciously accepted.

Had 'hash' been in its own module, I would consider simply including
hash.hpp, rather than relying on forward declarations, as 'hash' should be a
very lightweight module.

Boost list run by bdawes at, gregod at, cpdaniel at, john at