1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

CanonPath: Implement boost::hash

This commit is contained in:
Eelco Dolstra 2025-09-08 08:07:34 +02:00
parent 7f9b5226af
commit 8fbf4b9427

View file

@ -8,6 +8,8 @@
#include <set>
#include <vector>
#include <boost/container_hash/hash.hpp>
namespace nix {
/**
@ -258,11 +260,17 @@ public:
*/
std::string makeRelative(const CanonPath & path) const;
friend struct std::hash<CanonPath>;
friend std::size_t hash_value(const CanonPath &);
};
std::ostream & operator<<(std::ostream & stream, const CanonPath & path);
inline std::size_t hash_value(const CanonPath & path)
{
boost::hash<std::string_view> hasher;
return hasher(path.path);
}
} // namespace nix
template<>
@ -270,8 +278,8 @@ struct std::hash<nix::CanonPath>
{
using is_avalanching = std::true_type;
std::size_t operator()(const nix::CanonPath & s) const noexcept
std::size_t operator()(const nix::CanonPath & path) const noexcept
{
return std::hash<std::string>{}(s.path);
return nix::hash_value(path);
}
};