mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
CanonPath: Implement boost::hash
This commit is contained in:
parent
7f9b5226af
commit
8fbf4b9427
1 changed files with 11 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue