Skip to content

Commit

Permalink
Make cb map as hash table
Browse files Browse the repository at this point in the history
  • Loading branch information
qubka committed Dec 25, 2024
1 parent 7092f55 commit dd35839
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/hash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <utility>

namespace {
template<typename T, typename... Rest>
void hash_combine(std::size_t& seed, const T& v, const Rest&... rest) {
seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
(hash_combine(seed, rest), ...);
}
}

template<typename T1, typename T2>
struct std::hash<std::pair<T1, T2>> {
std::size_t operator()(std::pair<T1, T2> const& p) const noexcept {
std::size_t seed{};
hash_combine(seed, p.first, p.second);
return seed;
}
};
1 change: 1 addition & 0 deletions src/plugin.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "callback.hpp"
#include "hash.hpp"

#include <plugify/cpp_plugin.hpp>
#include <plugin_export.h>
Expand Down

0 comments on commit dd35839

Please sign in to comment.