Skip to content

Commit 3da5a68

Browse files
committed
Intermediate changes
1 parent a8b8852 commit 3da5a68

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

util/generic/string_transparent_hash_ut.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@
33
#include "strbuf.h"
44

55
#include <library/cpp/testing/unittest/registar.h>
6-
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
76

87
#include <util/str_stl.h>
98

9+
#ifdef __cpp_lib_generic_unordered_lookup
10+
#include <unordered_set>
11+
12+
template <class T, class THasher, class TPred>
13+
using THashSetType = std::unordered_set<T, THasher, TPred>;
14+
#else
15+
// Using Abseil hash set because `std::unordered_set` is transparent only from libstdc++11.
16+
// Meanwhile clang-linux-x86_64-release-stl-system autocheck sets OS_SDK=ubuntu-20,
17+
// that support libstdc++10 by default.
18+
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
19+
20+
template <class T, class THasher, class TPred>
21+
using THashSetType = absl::flat_hash_set<T, THasher, TPred>;
22+
#endif
23+
1024
Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
1125
Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
12-
// Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
13-
// we stuck with C++17 right now).
14-
absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
26+
THashSetType<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
1527
// If either `THash` or `TEqualTo` is not transparent compilation will fail.
1628
UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
1729
UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());

util/generic/ut/ya.make

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SRCS(
4141
generic/stack_ut.cpp
4242
generic/store_policy_ut.cpp
4343
generic/strbuf_ut.cpp
44+
generic/string_transparent_hash_ut.cpp
4445
generic/string_ut.cpp
4546
generic/typelist_ut.cpp
4647
generic/typetraits_ut.cpp
@@ -56,16 +57,8 @@ SRCS(
5657

5758
INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc)
5859

59-
IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
60-
# Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
61-
# (somewhere in unscaledcycleclock.cc).
62-
PEERDIR(
63-
library/cpp/containers/absl_flat_hash
64-
)
65-
66-
SRCS(
67-
generic/string_transparent_hash_ut.cpp
68-
)
69-
ENDIF()
60+
PEERDIR(
61+
library/cpp/containers/absl_flat_hash
62+
)
7063

7164
END()

0 commit comments

Comments
 (0)