userver: userver/utils/str_icase.hpp Source File
Loading...
Searching...
No Matches
str_icase.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <cstdint>
8#include <string_view>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace utils {
13
15struct HashSeed final {
16 std::uint64_t k0;
17 std::uint64_t k1;
18};
19
22public:
23 using is_transparent [[maybe_unused]] = void;
24
27
30 explicit StrCaseHash(HashSeed seed) noexcept;
31
32 std::size_t operator()(std::string_view s) const& noexcept;
33
34 template <class StringStrongTypedef>
35 auto operator()(const StringStrongTypedef& s
36 ) const& noexcept -> decltype(operator()(std::string_view{s.GetUnderlying()})) {
37 static_assert(
38 noexcept((*this)(std::string_view{s.GetUnderlying()})),
39 "GetUnderlying() should not throw as this affects efficiency "
40 "on some platforms"
41 );
42
43 return (*this)(std::string_view{s.GetUnderlying()});
44 }
45
46 HashSeed GetSeed() const noexcept { return seed_; }
47
48private:
49 HashSeed seed_;
50};
51
54public:
55 using is_transparent [[maybe_unused]] = void;
56
59
62 explicit StrIcaseHash(HashSeed seed) noexcept;
63
64 std::size_t operator()(std::string_view s) const& noexcept;
65
66private:
67 HashSeed seed_;
68};
69
72public:
73 // TODO: std::weak_ordering
74
76 int operator()(std::string_view lhs, std::string_view rhs) const noexcept;
77};
78
81public:
82 using is_transparent [[maybe_unused]] = void;
83
84 bool operator()(std::string_view lhs, std::string_view rhs) const noexcept;
85};
86
89public:
90 using is_transparent [[maybe_unused]] = void;
91
92 bool operator()(std::string_view lhs, std::string_view rhs) const noexcept;
93};
94
95} // namespace utils
96
97USERVER_NAMESPACE_END