aboutsummaryrefslogtreecommitdiffstats
path: root/util/str_stl.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/str_stl.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/str_stl.h')
-rw-r--r--util/str_stl.h154
1 files changed, 77 insertions, 77 deletions
diff --git a/util/str_stl.h b/util/str_stl.h
index 2c9991ff21..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -1,51 +1,51 @@
#pragma once
-#include <util/memory/alloc.h>
-#include <util/digest/numeric.h>
+#include <util/memory/alloc.h>
+#include <util/digest/numeric.h>
#include <util/generic/string.h>
#include <util/generic/string_hash.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
-
+
#include <functional>
#include <typeindex>
#include <utility>
-
-namespace std {
- template <>
+
+namespace std {
+ template <>
struct less<const char*> {
- bool operator()(const char* x, const char* y) const {
- return strcmp(x, y) < 0;
- }
- };
- template <>
+ bool operator()(const char* x, const char* y) const {
+ return strcmp(x, y) < 0;
+ }
+ };
+ template <>
struct equal_to<const char*> {
- bool operator()(const char* x, const char* y) const {
- return strcmp(x, y) == 0;
- }
+ bool operator()(const char* x, const char* y) const {
+ return strcmp(x, y) == 0;
+ }
bool operator()(const char* x, const TStringBuf y) const {
return strlen(x) == y.size() && memcmp(x, y.data(), y.size()) == 0;
}
using is_transparent = void;
- };
-}
+ };
+}
-namespace NHashPrivate {
- template <class T, bool needNumericHashing>
- struct THashHelper {
+namespace NHashPrivate {
+ template <class T, bool needNumericHashing>
+ struct THashHelper {
inline size_t operator()(const T& t) const noexcept {
return (size_t)t; // If you have a compilation error here, look at explanation below:
// Probably error is caused by undefined template specialization of THash<T>
// You can find examples of specialization in this file
- }
- };
-
- template <class T>
- struct THashHelper<T, true> {
+ }
+ };
+
+ template <class T>
+ struct THashHelper<T, true> {
inline size_t operator()(const T& t) const noexcept {
- return NumericHash(t);
- }
- };
+ return NumericHash(t);
+ }
+ };
template <typename C>
struct TStringHash {
@@ -55,53 +55,53 @@ namespace NHashPrivate {
return NHashPrivate::ComputeStringHash(s.data(), s.size());
}
};
-}
-
-template <class T>
+}
+
+template <class T>
struct hash: public NHashPrivate::THashHelper<T, std::is_scalar<T>::value && !std::is_integral<T>::value> {
};
-template <typename T>
+template <typename T>
struct hash<const T*> {
inline size_t operator()(const T* t) const noexcept {
- return NumericHash(t);
+ return NumericHash(t);
}
};
-template <class T>
+template <class T>
struct hash<T*>: public ::hash<const T*> {
-};
-
-template <>
-struct hash<const char*>: ::NHashPrivate::TStringHash<char> {
};
template <>
-struct THash<TStringBuf>: ::NHashPrivate::TStringHash<char> {
+struct hash<const char*>: ::NHashPrivate::TStringHash<char> {
+};
+
+template <>
+struct THash<TStringBuf>: ::NHashPrivate::TStringHash<char> {
};
template <>
-struct hash<TString>: ::NHashPrivate::TStringHash<char> {
+struct hash<TString>: ::NHashPrivate::TStringHash<char> {
};
template <>
-struct hash<TUtf16String>: ::NHashPrivate::TStringHash<wchar16> {
+struct hash<TUtf16String>: ::NHashPrivate::TStringHash<wchar16> {
};
template <>
-struct THash<TWtringBuf>: ::NHashPrivate::TStringHash<wchar16> {
+struct THash<TWtringBuf>: ::NHashPrivate::TStringHash<wchar16> {
};
template <>
-struct hash<TUtf32String>: ::NHashPrivate::TStringHash<wchar32> {
+struct hash<TUtf32String>: ::NHashPrivate::TStringHash<wchar32> {
};
template <>
-struct THash<TUtf32StringBuf>: ::NHashPrivate::TStringHash<wchar32> {
+struct THash<TUtf32StringBuf>: ::NHashPrivate::TStringHash<wchar32> {
};
template <class C, class T, class A>
-struct hash<std::basic_string<C, T, A>>: ::NHashPrivate::TStringHash<C> {
+struct hash<std::basic_string<C, T, A>>: ::NHashPrivate::TStringHash<C> {
};
template <>
@@ -121,7 +121,7 @@ namespace NHashPrivate {
struct TupleHashHelper {
Y_FORCE_INLINE static size_t Hash(const std::tuple<TArgs...>& tuple) {
return CombineHashes(HashObject(std::get<I>(tuple)),
- TupleHashHelper<I + 1, I + 2 >= sizeof...(TArgs), TArgs...>::Hash(tuple));
+ TupleHashHelper<I + 1, I + 2 >= sizeof...(TArgs), TArgs...>::Hash(tuple));
}
};
@@ -132,7 +132,7 @@ namespace NHashPrivate {
}
};
-}
+}
template <typename... TArgs>
struct THash<std::tuple<TArgs...>> {
@@ -142,7 +142,7 @@ struct THash<std::tuple<TArgs...>> {
};
template <class T>
-struct THash: public ::hash<T> {
+struct THash: public ::hash<T> {
};
namespace NHashPrivate {
@@ -151,9 +151,9 @@ namespace NHashPrivate {
private:
THash<TFirst> FirstHash;
THash<TSecond> SecondHash;
-
+
public:
- template <class T>
+ template <class T>
inline size_t operator()(const T& pair) const {
return CombineHashes(FirstHash(pair.first), SecondHash(pair.second));
}
@@ -166,7 +166,7 @@ namespace NHashPrivate {
*/
template <class TFirst, class TSecond>
struct TPairHash<TFirst, TSecond, true> {
- template <class T>
+ template <class T>
inline size_t operator()(const T& pair) const {
// maps have TFirst = const TFoo, which would make for an undefined specialization
using TFirstClean = std::remove_cv_t<TFirst>;
@@ -174,16 +174,16 @@ namespace NHashPrivate {
return CombineHashes(THash<TFirstClean>()(pair.first), THash<TSecondClean>()(pair.second));
}
};
-}
+}
template <class TFirst, class TSecond>
-struct hash<std::pair<TFirst, TSecond>>: public NHashPrivate::TPairHash<TFirst, TSecond> {
-};
+struct hash<std::pair<TFirst, TSecond>>: public NHashPrivate::TPairHash<TFirst, TSecond> {
+};
template <class T>
-struct TEqualTo: public std::equal_to<T> {
-};
-
+struct TEqualTo: public std::equal_to<T> {
+};
+
template <>
struct TEqualTo<TString>: public TEqualTo<TStringBuf> {
using is_transparent = void;
@@ -192,24 +192,24 @@ struct TEqualTo<TString>: public TEqualTo<TStringBuf> {
template <>
struct TEqualTo<TUtf16String>: public TEqualTo<TWtringBuf> {
using is_transparent = void;
-};
-
+};
+
template <>
-struct TEqualTo<TUtf32String>: public TEqualTo<TUtf32StringBuf> {
+struct TEqualTo<TUtf32String>: public TEqualTo<TUtf32StringBuf> {
using is_transparent = void;
};
-template <class TFirst, class TSecond>
+template <class TFirst, class TSecond>
struct TEqualTo<std::pair<TFirst, TSecond>> {
- template <class TOther>
+ template <class TOther>
inline bool operator()(const std::pair<TFirst, TSecond>& a, const TOther& b) const {
return TEqualTo<TFirst>()(a.first, b.first) && TEqualTo<TSecond>()(a.second, b.second);
}
using is_transparent = void;
};
-template <class T>
-struct TCIEqualTo {
+template <class T>
+struct TCIEqualTo {
};
template <>
@@ -234,39 +234,39 @@ struct TCIEqualTo<TString> {
};
template <class T>
-struct TLess: public std::less<T> {
-};
+struct TLess: public std::less<T> {
+};
-template <>
+template <>
struct TLess<TString>: public TLess<TStringBuf> {
using is_transparent = void;
};
-template <>
+template <>
struct TLess<TUtf16String>: public TLess<TWtringBuf> {
using is_transparent = void;
-};
-
+};
+
template <>
-struct TLess<TUtf32String>: public TLess<TUtf32StringBuf> {
+struct TLess<TUtf32String>: public TLess<TUtf32StringBuf> {
using is_transparent = void;
};
template <class T>
-struct TGreater: public std::greater<T> {
+struct TGreater: public std::greater<T> {
};
-template <>
+template <>
struct TGreater<TString>: public TGreater<TStringBuf> {
using is_transparent = void;
-};
-
-template <>
+};
+
+template <>
struct TGreater<TUtf16String>: public TGreater<TWtringBuf> {
using is_transparent = void;
-};
+};
template <>
-struct TGreater<TUtf32String>: public TGreater<TUtf32StringBuf> {
+struct TGreater<TUtf32String>: public TGreater<TUtf32StringBuf> {
using is_transparent = void;
};