Skip to content

Commit

Permalink
Add std::hash<podio::ObjectID> specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Feb 11, 2025
1 parent c9f1d04 commit 789f3c2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/podio/ObjectID.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PODIO_OBJECTID_H

#include <cstdint>
#include <functional>
#include <iomanip>
#include <ostream>

Expand Down Expand Up @@ -49,4 +50,16 @@ inline void to_json(nlohmann::json& j, const podio::ObjectID& id) {

} // namespace podio

template<>
struct std::hash<podio::ObjectID>
{
std::size_t operator()(const podio::ObjectID& id) const noexcept
{
auto hash_collectionID = std::hash<uint32_t>{}(id.collectionID);
auto hash_index = std::hash<int>{}(id.index);

return hash_collectionID ^ hash_index;
}
};

#endif

0 comments on commit 789f3c2

Please sign in to comment.