Skip to content

Commit 1643e74

Browse files
committed
SourcePath: Implement boost::hash
1 parent 2df0080 commit 1643e74

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/libutil/include/nix/util/source-path.hh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,21 @@ struct SourcePath
119119

120120
std::ostream & operator<<(std::ostream & str, const SourcePath & path);
121121

122+
inline std::size_t hash_value(const SourcePath & path)
123+
{
124+
std::size_t hash = 0;
125+
boost::hash_combine(hash, path.accessor->number);
126+
boost::hash_combine(hash, path.path);
127+
return hash;
128+
}
129+
122130
} // namespace nix
123131

124132
template<>
125133
struct std::hash<nix::SourcePath>
126134
{
127135
std::size_t operator()(const nix::SourcePath & s) const noexcept
128136
{
129-
std::size_t hash = 0;
130-
hash_combine(hash, s.accessor->number, s.path);
131-
return hash;
137+
return nix::hash_value(s);
132138
}
133139
};

0 commit comments

Comments
 (0)