userver: /home/antonyzhilin/arcadia/taxi/uservices/userver/libraries/proto-structs/include/userver/proto-structs/hash_map.hpp Source File
Loading...
Searching...
No Matches
hash_map.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief @copybrief proto_structs::HashMap
5
6#include <type_traits>
7#include <unordered_map>
8
9#include <userver/utils/str_icase.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace proto_structs {
14
15/// @brief The hash map container used in userver proto structs by default.
16///
17/// Currently implemented as just `std::unordered_map`. Please don't assume it! For example:
18///
19/// * Don't pass the field to functions as `std::unordered_map`, use `proto_structs::HashMap` instead;
20/// * Don't use node and bucket APIs of `std::unordered_map` with these fields.
21template <typename Key, typename Value>
22using HashMap = std::unordered_map<
23 Key,
24 Value,
25 std::conditional_t<std::is_convertible_v<Key, std::string_view>, utils::StrCaseHash, std::hash<Key>>>;
26
27} // namespace proto_structs
28
29USERVER_NAMESPACE_END