On this page
article
peary/utils/enum_hash_map.hpp
peary/utils/enum_hash_map.hpp
Unordered enum map using hashes for fast lookup. More…
Namespaces
| Name |
|---|
| peary |
| peary::utils |
Classes
| Name | |
|---|---|
| struct | peary::utils::enum_hash |
Detailed Description
Unordered enum map using hashes for fast lookup.
Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only
Source code
#pragma once
#include <cstdlib>
#include <functional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
namespace peary::utils {
template <typename E> struct enum_hash {
[[nodiscard]] std::size_t operator()(E e) const noexcept { return static_cast<std::size_t>(e); }
};
template <typename E, typename V> using enum_hash_map = std::unordered_map<E, V, enum_hash<E>>;
template <typename E> using enum_hash_set = std::unordered_set<E, enum_hash<E>>;
} // namespace peary::utils
Updated on 2026-01-30 at 22:01:05 +0100