Slick Trader 0.11.0
Multi-broker algorithmic trading engine with plugin strategies and a live web dashboard
Loading...
Searching...
No Matches
string_hash.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <functional>
5#include <string>
6#include <string_view>
7#include <unordered_map>
8#include <unordered_set>
9
10namespace slick::trader {
11
12// Lets an unordered map keyed by std::string be searched with a std::string_view, such as an
13// event's instrument, with no string built: declare it with StringHash and std::equal_to<>.
14struct StringHash {
15 using is_transparent = void;
16 std::size_t operator()(std::string_view s) const noexcept { return std::hash<std::string_view>{}(s); }
17};
18
19// A set of strings searched the same way.
20using StringSet = std::unordered_set<std::string, StringHash, std::equal_to<>>;
21
22// And a map keyed by them.
23template <typename V>
24using StringMap = std::unordered_map<std::string, V, StringHash, std::equal_to<>>;
25
26} // namespace slick::trader
std::unordered_set< std::string, StringHash, std::equal_to<> > StringSet
std::unordered_map< std::string, V, StringHash, std::equal_to<> > StringMap
std::size_t operator()(std::string_view s) const noexcept