|
3 | 3 | #include "strbuf.h"
|
4 | 4 |
|
5 | 5 | #include <library/cpp/testing/unittest/registar.h>
|
6 |
| -#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h> |
7 | 6 |
|
8 | 7 | #include <util/str_stl.h>
|
9 | 8 |
|
| 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 | + |
10 | 24 | Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
|
11 | 25 | 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"}; |
15 | 27 | // If either `THash` or `TEqualTo` is not transparent compilation will fail.
|
16 | 28 | UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
|
17 | 29 | UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
|
|
0 commit comments