Replace boost::hash by std::hash (#6892)

* Replace boost::hash by std::hash

* Fix formatting

* Update CHANGELOG.md
This commit is contained in:
Dennis Luxen
2024-05-23 14:35:56 +02:00
committed by GitHub
parent 73fb53cf36
commit 46dc660801
16 changed files with 93 additions and 126 deletions
+7 -5
View File
@@ -1,15 +1,14 @@
#ifndef OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
#define OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
#include "util/std_hash.hpp"
#include "util/typedefs.hpp"
#include <cstddef>
#include <cstdint>
#include <functional>
#include <vector>
#include <boost/functional/hash.hpp>
#include "util/typedefs.hpp"
namespace osrm::util::guidance
{
class BearingClass;
@@ -62,7 +61,10 @@ namespace std
inline size_t hash<::osrm::util::guidance::BearingClass>::operator()(
const ::osrm::util::guidance::BearingClass &bearing_class) const
{
return boost::hash_value(bearing_class.available_bearings);
std::size_t value = 0;
hash_range(
value, bearing_class.available_bearings.cbegin(), bearing_class.available_bearings.cend());
return value;
}
} // namespace std
+28 -32
View File
@@ -1,36 +1,22 @@
#ifndef OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
#define OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
#include "util/concurrent_id_map.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp"
#include <cstddef>
#include <cstdint>
#include <functional>
#include <unordered_map>
#include <vector>
#include "util/concurrent_id_map.hpp"
#include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
namespace osrm::util::guidance
{
class LaneTuple;
class LaneTupleIdPair;
} // namespace osrm::util::guidance
namespace std
{
template <> struct hash<::osrm::util::guidance::LaneTuple>
{
inline std::size_t operator()(const ::osrm::util::guidance::LaneTuple &bearing_class) const;
};
template <> struct hash<::osrm::util::guidance::LaneTupleIdPair>
{
inline std::size_t
operator()(const ::osrm::util::guidance::LaneTupleIdPair &bearing_class) const;
};
} // namespace std
namespace osrm::util::guidance
{
@@ -61,14 +47,6 @@ class LaneTuple
LaneID lanes_in_turn;
LaneID first_lane_from_the_right; // is INVALID_LANEID when no lanes present
friend std::size_t hash_value(const LaneTuple &tup)
{
std::size_t seed{0};
boost::hash_combine(seed, tup.lanes_in_turn);
boost::hash_combine(seed, tup.first_lane_from_the_right);
return seed;
}
};
class LaneTupleIdPair
@@ -78,18 +56,36 @@ class LaneTupleIdPair
LaneDescriptionID second;
bool operator==(const LaneTupleIdPair &other) const;
};
friend std::size_t hash_value(const LaneTupleIdPair &pair)
using LaneDataIdMap = ConcurrentIDMap<LaneTupleIdPair, LaneDataID>;
} // namespace osrm::util::guidance
namespace std
{
template <> struct hash<::osrm::util::guidance::LaneTuple>
{
inline std::size_t operator()(const ::osrm::util::guidance::LaneTuple &lane_tuple) const
{
std::size_t seed{0};
boost::hash_combine(seed, pair.first);
boost::hash_combine(seed, pair.second);
hash_combine(seed, lane_tuple.lanes_in_turn);
hash_combine(seed, lane_tuple.first_lane_from_the_right);
return seed;
}
};
using LaneDataIdMap = ConcurrentIDMap<LaneTupleIdPair, LaneDataID, boost::hash<LaneTupleIdPair>>;
} // namespace osrm::util::guidance
template <> struct hash<::osrm::util::guidance::LaneTupleIdPair>
{
inline std::size_t
operator()(const ::osrm::util::guidance::LaneTupleIdPair &lane_tuple_id_pair) const
{
std::size_t seed{0};
hash_combine(seed, lane_tuple_id_pair.first);
hash_combine(seed, lane_tuple_id_pair.second);
return seed;
}
};
} // namespace std
#endif /* OSRM_UTIL_GUIDANCE_TURN_LANES_HPP */