Skip to content

Commit

Permalink
Replace std::hash with abs::Hash from the abseil library to make hash…
Browse files Browse the repository at this point in the history
…ing reproducible on different systems
  • Loading branch information
Jean1995 committed Oct 12, 2023
1 parent c3b01b7 commit d6d40a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def requirements(self):
self.requires("spdlog/1.11.0", transitive_headers=True, transitive_libs=True)
# nlohmann_json: public headers include json.hpp and json_fwd.hpp
self.requires("nlohmann_json/3.11.2", transitive_headers=True)
self.requires("20230125.3")
if self.options.with_python:
self.requires("pybind11/2.10.1")
if self.options.with_testing:
Expand Down
2 changes: 2 additions & 0 deletions src/PROPOSAL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_include_directories(PROPOSAL PUBLIC
find_package(CubicInterpolation REQUIRED)
find_package(spdlog REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(absl REQUIRED)

add_subdirectory(PROPOSAL)
add_subdirectory(detail)
Expand All @@ -26,6 +27,7 @@ target_link_libraries(PROPOSAL
CubicInterpolation::CubicInterpolation
spdlog::spdlog
nlohmann_json::nlohmann_json
absl::hash
)

install(TARGETS PROPOSAL EXPORT PROPOSALTargets
Expand Down
3 changes: 2 additions & 1 deletion src/PROPOSAL/PROPOSAL/methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <memory>
#include <vector>
#include <sys/stat.h>
#include "absl/hash/hash.h"
// use unistd.h for access on POSIX os, use io.h for windows systems
// todo: use filesystem instead when switching to c++17
#ifdef _WIN32
Expand Down Expand Up @@ -77,7 +78,7 @@ inline void hash_combine(std::size_t& seed) { (void)seed; }
template <typename T, typename... Rest>
inline void hash_combine(std::size_t& seed, const T& v, Rest... rest)
{
std::hash<T> hasher;
absl::Hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
hash_combine(seed, rest...);
}
Expand Down

0 comments on commit d6d40a1

Please sign in to comment.