dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
StringMap.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <map>
13#include <memory>
14#include <string_view>
15#include <unordered_map>
16#include <utility>
17
18namespace dfx::Utils
19{
31{
33 using is_transparent = void;
34
38 std::size_t operator()(std::string_view str) const noexcept
39 { return std::hash<std::string_view>{}(str); }
40};
41
49{
51 using is_transparent = void;
52
57 bool operator()(std::string_view lhs, std::string_view rhs) const noexcept
58 { return lhs == rhs; }
59};
60
66using TransparentLess = std::less<>;
67
75template<typename T, typename Allocator = std::allocator<std::pair<std::string const, T>>>
76using UnorderedStringMap = std::unordered_map<std::string, T, TransparentHash, TransparentEqual, Allocator>;
77
85template<typename T, typename Allocator = std::allocator<std::pair<std::string const, T>>>
86using StringMap = std::map<std::string, T, TransparentLess, Allocator>;
87} // !namespace dfx::Utils
Definition SystemConfigCommandHandler.hpp:15
std::unordered_map< std::string, T, TransparentHash, TransparentEqual, Allocator > UnorderedStringMap
Convenience alias for an unordered map keyed by std::string with transparent lookup.
Definition StringMap.hpp:76
std::map< std::string, T, TransparentLess, Allocator > StringMap
Convenience alias for an ordered map keyed by std::string with transparent lookup.
Definition StringMap.hpp:86
std::less<> TransparentLess
Comparator alias enabling transparent ordered lookup.
Definition StringMap.hpp:66
Transparent equality predicate for string-like lookups.
Definition StringMap.hpp:49
void is_transparent
Marker enabling heterogeneous lookup in standard associative containers.
Definition StringMap.hpp:51
bool operator()(std::string_view lhs, std::string_view rhs) const noexcept
Compare two string views.
Definition StringMap.hpp:57
Transparent hash functor for string-like lookups.
Definition StringMap.hpp:31
void is_transparent
Marker enabling heterogeneous lookup in standard associative containers.
Definition StringMap.hpp:33
std::size_t operator()(std::string_view str) const noexcept
Hash a string view.
Definition StringMap.hpp:38