aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-09-03 12:30:50 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-09-03 12:42:57 +0300
commit3da5a68ec3c329240e89bd0ed8c1c39e4359a693 (patch)
treeddde18bdffca562c82d38999ff77f5ee6be185e9 /util
parenta8b88523909e5ff941fbccbc1fcaabc0d91fffdb (diff)
downloadydb-3da5a68ec3c329240e89bd0ed8c1c39e4359a693.tar.gz
Intermediate changes
Diffstat (limited to 'util')
-rw-r--r--util/generic/string_transparent_hash_ut.cpp20
-rw-r--r--util/generic/ut/ya.make15
2 files changed, 20 insertions, 15 deletions
diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp
index b87fa2843e..a03fc7e6d7 100644
--- a/util/generic/string_transparent_hash_ut.cpp
+++ b/util/generic/string_transparent_hash_ut.cpp
@@ -3,15 +3,27 @@
#include "strbuf.h"
#include <library/cpp/testing/unittest/registar.h>
-#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
#include <util/str_stl.h>
+#ifdef __cpp_lib_generic_unordered_lookup
+ #include <unordered_set>
+
+template <class T, class THasher, class TPred>
+using THashSetType = std::unordered_set<T, THasher, TPred>;
+#else
+ // Using Abseil hash set because `std::unordered_set` is transparent only from libstdc++11.
+ // Meanwhile clang-linux-x86_64-release-stl-system autocheck sets OS_SDK=ubuntu-20,
+ // that support libstdc++10 by default.
+ #include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
+
+template <class T, class THasher, class TPred>
+using THashSetType = absl::flat_hash_set<T, THasher, TPred>;
+#endif
+
Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
- // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
- // we stuck with C++17 right now).
- absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
+ THashSetType<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
// If either `THash` or `TEqualTo` is not transparent compilation will fail.
UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make
index 35bdb72bd4..38978e129d 100644
--- a/util/generic/ut/ya.make
+++ b/util/generic/ut/ya.make
@@ -41,6 +41,7 @@ SRCS(
generic/stack_ut.cpp
generic/store_policy_ut.cpp
generic/strbuf_ut.cpp
+ generic/string_transparent_hash_ut.cpp
generic/string_ut.cpp
generic/typelist_ut.cpp
generic/typetraits_ut.cpp
@@ -56,16 +57,8 @@ SRCS(
INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc)
-IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
- # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
- # (somewhere in unscaledcycleclock.cc).
- PEERDIR(
- library/cpp/containers/absl_flat_hash
- )
-
- SRCS(
- generic/string_transparent_hash_ut.cpp
- )
-ENDIF()
+PEERDIR(
+ library/cpp/containers/absl_flat_hash
+)
END()