bloaty/third_party/abseil-cpp/absl/hash/hash_test.cc
Go to the documentation of this file.
1 // Copyright 2018 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/hash/hash.h"
16 
17 #include <array>
18 #include <bitset>
19 #include <cstring>
20 #include <deque>
21 #include <forward_list>
22 #include <functional>
23 #include <iterator>
24 #include <limits>
25 #include <list>
26 #include <map>
27 #include <memory>
28 #include <numeric>
29 #include <random>
30 #include <set>
31 #include <string>
32 #include <tuple>
33 #include <type_traits>
34 #include <unordered_map>
35 #include <utility>
36 #include <vector>
37 
38 #include "gmock/gmock.h"
39 #include "gtest/gtest.h"
40 #include "absl/container/flat_hash_set.h"
41 #include "absl/hash/hash_testing.h"
42 #include "absl/hash/internal/spy_hash_state.h"
43 #include "absl/meta/type_traits.h"
44 #include "absl/numeric/int128.h"
45 #include "absl/strings/cord_test_helpers.h"
46 
47 namespace {
48 
49 using absl::Hash;
51 
52 template <typename T>
53 class HashValueIntTest : public testing::Test {
54 };
55 TYPED_TEST_SUITE_P(HashValueIntTest);
56 
57 template <typename T>
58 SpyHashState SpyHash(const T& value) {
59  return SpyHashState::combine(SpyHashState(), value);
60 }
61 
62 // Helper trait to verify if T is hashable. We use absl::Hash's poison status to
63 // detect it.
64 template <typename T>
65 using is_hashable = std::is_default_constructible<absl::Hash<T>>;
66 
67 TYPED_TEST_P(HashValueIntTest, BasicUsage) {
69 
70  TypeParam n = 42;
71  EXPECT_EQ(SpyHash(n), SpyHash(TypeParam{42}));
72  EXPECT_NE(SpyHash(n), SpyHash(TypeParam{0}));
75 }
76 
77 TYPED_TEST_P(HashValueIntTest, FastPath) {
78  // Test the fast-path to make sure the values are the same.
79  TypeParam n = 42;
81  absl::Hash<std::tuple<TypeParam>>{}(std::tuple<TypeParam>(n)));
82 }
83 
84 REGISTER_TYPED_TEST_CASE_P(HashValueIntTest, BasicUsage, FastPath);
85 using IntTypes = testing::Types<unsigned char, char, int, int32_t, int64_t,
86  uint32_t, uint64_t, size_t>;
87 INSTANTIATE_TYPED_TEST_CASE_P(My, HashValueIntTest, IntTypes);
88 
89 enum LegacyEnum { kValue1, kValue2, kValue3 };
90 
91 enum class EnumClass { kValue4, kValue5, kValue6 };
92 
93 TEST(HashValueTest, EnumAndBool) {
97 
99  LegacyEnum::kValue1, LegacyEnum::kValue2, LegacyEnum::kValue3)));
101  EnumClass::kValue4, EnumClass::kValue5, EnumClass::kValue6)));
103  std::make_tuple(true, false)));
104 }
105 
106 TEST(HashValueTest, FloatingPoint) {
110 
112  std::make_tuple(42.f, 0.f, -0.f, std::numeric_limits<float>::infinity(),
113  -std::numeric_limits<float>::infinity())));
114 
116  std::make_tuple(42., 0., -0., std::numeric_limits<double>::infinity(),
117  -std::numeric_limits<double>::infinity())));
118 
120  // Add some values with small exponent to test that NORMAL values also
121  // append their category.
122  .5L, 1.L, 2.L, 4.L, 42.L, 0.L, -0.L,
123  17 * static_cast<long double>(std::numeric_limits<double>::max()),
124  std::numeric_limits<long double>::infinity(),
125  -std::numeric_limits<long double>::infinity())));
126 }
127 
128 TEST(HashValueTest, Pointer) {
130 
131  int i;
132  int* ptr = &i;
133  int* n = nullptr;
134 
136  std::make_tuple(&i, ptr, nullptr, ptr + 1, n)));
137 }
138 
139 TEST(HashValueTest, PointerAlignment) {
140  // We want to make sure that pointer alignment will not cause bits to be
141  // stuck.
142 
143  constexpr size_t kTotalSize = 1 << 20;
144  std::unique_ptr<char[]> data(new char[kTotalSize]);
145  constexpr size_t kLog2NumValues = 5;
146  constexpr size_t kNumValues = 1 << kLog2NumValues;
147 
148  for (size_t align = 1; align < kTotalSize / kNumValues;
149  align < 8 ? align += 1 : align < 1024 ? align += 8 : align += 32) {
151  ASSERT_LE(align * kNumValues, kTotalSize);
152 
153  size_t bits_or = 0;
154  size_t bits_and = ~size_t{};
155 
156  for (size_t i = 0; i < kNumValues; ++i) {
157  size_t hash = absl::Hash<void*>()(data.get() + i * align);
158  bits_or |= hash;
159  bits_and &= hash;
160  }
161 
162  // Limit the scope to the bits we would be using for Swisstable.
163  constexpr size_t kMask = (1 << (kLog2NumValues + 7)) - 1;
164  size_t stuck_bits = (~bits_or | bits_and) & kMask;
165  EXPECT_EQ(stuck_bits, 0) << "0x" << std::hex << stuck_bits;
166  }
167 }
168 
169 TEST(HashValueTest, PairAndTuple) {
170  EXPECT_TRUE((is_hashable<std::pair<int, int>>::value));
171  EXPECT_TRUE((is_hashable<std::pair<const int&, const int&>>::value));
172  EXPECT_TRUE((is_hashable<std::tuple<int&, int&>>::value));
173  EXPECT_TRUE((is_hashable<std::tuple<int&&, int&&>>::value));
174 
176  std::make_pair(0, 42), std::make_pair(0, 42), std::make_pair(42, 0),
177  std::make_pair(0, 0), std::make_pair(42, 42), std::make_pair(1, 42))));
178 
180  std::make_tuple(std::make_tuple(0, 0, 0), std::make_tuple(0, 0, 42),
181  std::make_tuple(0, 23, 0), std::make_tuple(17, 0, 0),
182  std::make_tuple(42, 0, 0), std::make_tuple(3, 9, 9),
183  std::make_tuple(0, 0, -42))));
184 
185  // Test that tuples of lvalue references work (so we need a few lvalues):
186  int a = 0, b = 1, c = 17, d = 23;
188  std::tie(a, a), std::tie(a, b), std::tie(b, c), std::tie(c, d))));
189 
190  // Test that tuples of rvalue references work:
192  std::forward_as_tuple(0, 0, 0), std::forward_as_tuple(0, 0, 42),
193  std::forward_as_tuple(0, 23, 0), std::forward_as_tuple(17, 0, 0),
194  std::forward_as_tuple(42, 0, 0), std::forward_as_tuple(3, 9, 9),
195  std::forward_as_tuple(0, 0, -42))));
196 }
197 
198 TEST(HashValueTest, CombineContiguousWorks) {
199  std::vector<std::tuple<int>> v1 = {std::make_tuple(1), std::make_tuple(3)};
200  std::vector<std::tuple<int>> v2 = {std::make_tuple(1), std::make_tuple(2)};
201 
202  auto vh1 = SpyHash(v1);
203  auto vh2 = SpyHash(v2);
204  EXPECT_NE(vh1, vh2);
205 }
206 
207 struct DummyDeleter {
208  template <typename T>
209  void operator() (T* ptr) {}
210 };
211 
212 struct SmartPointerEq {
213  template <typename T, typename U>
214  bool operator()(const T& t, const U& u) const {
215  return GetPtr(t) == GetPtr(u);
216  }
217 
218  template <typename T>
219  static auto GetPtr(const T& t) -> decltype(&*t) {
220  return t ? &*t : nullptr;
221  }
222 
223  static std::nullptr_t GetPtr(std::nullptr_t) { return nullptr; }
224 };
225 
226 TEST(HashValueTest, SmartPointers) {
227  EXPECT_TRUE((is_hashable<std::unique_ptr<int>>::value));
228  EXPECT_TRUE((is_hashable<std::unique_ptr<int, DummyDeleter>>::value));
229  EXPECT_TRUE((is_hashable<std::shared_ptr<int>>::value));
230 
231  int i, j;
232  std::unique_ptr<int, DummyDeleter> unique1(&i);
233  std::unique_ptr<int, DummyDeleter> unique2(&i);
234  std::unique_ptr<int, DummyDeleter> unique_other(&j);
235  std::unique_ptr<int, DummyDeleter> unique_null;
236 
237  std::shared_ptr<int> shared1(&i, DummyDeleter());
238  std::shared_ptr<int> shared2(&i, DummyDeleter());
239  std::shared_ptr<int> shared_other(&j, DummyDeleter());
240  std::shared_ptr<int> shared_null;
241 
242  // Sanity check of the Eq function.
243  ASSERT_TRUE(SmartPointerEq{}(unique1, shared1));
244  ASSERT_FALSE(SmartPointerEq{}(unique1, shared_other));
245  ASSERT_TRUE(SmartPointerEq{}(unique_null, nullptr));
246  ASSERT_FALSE(SmartPointerEq{}(shared2, nullptr));
247 
249  std::forward_as_tuple(&i, nullptr, //
250  unique1, unique2, unique_null, //
251  absl::make_unique<int>(), //
252  shared1, shared2, shared_null, //
253  std::make_shared<int>()),
254  SmartPointerEq{}));
255 }
256 
257 TEST(HashValueTest, FunctionPointer) {
258  using Func = int (*)();
260 
261  Func p1 = [] { return 2; }, p2 = [] { return 1; };
263  std::make_tuple(p1, p2, nullptr)));
264 }
265 
266 struct WrapInTuple {
267  template <typename T>
268  std::tuple<int, T, size_t> operator()(const T& t) const {
269  return std::make_tuple(7, t, 0xdeadbeef);
270  }
271 };
272 
274  absl::Cord c(sv);
275  c.Flatten();
276  return c;
277 }
278 
280  if (sv.size() < 2) {
281  return absl::Cord(sv);
282  }
283  size_t halfway = sv.size() / 2;
284  std::vector<absl::string_view> parts = {sv.substr(0, halfway),
285  sv.substr(halfway)};
286  return absl::MakeFragmentedCord(parts);
287 }
288 
289 TEST(HashValueTest, Strings) {
291 
292  const std::string small = "foo";
293  const std::string dup = "foofoo";
294  const std::string large = std::string(2048, 'x'); // multiple of chunk size
295  const std::string huge = std::string(5000, 'a'); // not a multiple
296 
299  std::string(""), absl::string_view(""), absl::Cord(""), //
300  std::string(small), absl::string_view(small), absl::Cord(small), //
301  std::string(dup), absl::string_view(dup), absl::Cord(dup), //
303  std::string(huge), absl::string_view(huge), FlatCord(huge), //
304  FragmentedCord(huge))));
305 
306  // Also check that nested types maintain the same hash.
307  const WrapInTuple t{};
310  t(std::string("")), t(absl::string_view("")), t(absl::Cord("")), //
311  t(std::string(small)), t(absl::string_view(small)), //
312  t(absl::Cord(small)), //
313  t(std::string(dup)), t(absl::string_view(dup)), t(absl::Cord(dup)), //
315  t(absl::Cord(large)), //
316  t(std::string(huge)), t(absl::string_view(huge)), //
317  t(FlatCord(huge)), t(FragmentedCord(huge)))));
318 
319  // Make sure that hashing a `const char*` does not use its string-value.
320  EXPECT_NE(SpyHash(static_cast<const char*>("ABC")),
321  SpyHash(absl::string_view("ABC")));
322 }
323 
324 TEST(HashValueTest, WString) {
326 
328  std::wstring(), std::wstring(L"ABC"), std::wstring(L"ABC"),
329  std::wstring(L"Some other different string"),
330  std::wstring(L"Iñtërnâtiônàlizætiøn"))));
331 }
332 
333 TEST(HashValueTest, U16String) {
335 
337  std::u16string(), std::u16string(u"ABC"), std::u16string(u"ABC"),
338  std::u16string(u"Some other different string"),
339  std::u16string(u"Iñtërnâtiônàlizætiøn"))));
340 }
341 
342 TEST(HashValueTest, U32String) {
344 
346  std::u32string(), std::u32string(U"ABC"), std::u32string(U"ABC"),
347  std::u32string(U"Some other different string"),
348  std::u32string(U"Iñtërnâtiônàlizætiøn"))));
349 }
350 
351 TEST(HashValueTest, StdArray) {
352  EXPECT_TRUE((is_hashable<std::array<int, 3>>::value));
353 
355  std::make_tuple(std::array<int, 3>{}, std::array<int, 3>{{0, 23, 42}})));
356 }
357 
358 TEST(HashValueTest, StdBitset) {
359  EXPECT_TRUE((is_hashable<std::bitset<257>>::value));
360 
362  {std::bitset<2>("00"), std::bitset<2>("01"), std::bitset<2>("10"),
363  std::bitset<2>("11")}));
365  {std::bitset<5>("10101"), std::bitset<5>("10001"), std::bitset<5>()}));
366 
367  constexpr int kNumBits = 256;
368  std::array<std::string, 6> bit_strings;
369  bit_strings.fill(std::string(kNumBits, '1'));
370  bit_strings[1][0] = '0';
371  bit_strings[2][1] = '0';
372  bit_strings[3][kNumBits / 3] = '0';
373  bit_strings[4][kNumBits - 2] = '0';
374  bit_strings[5][kNumBits - 1] = '0';
376  {std::bitset<kNumBits>(bit_strings[0].c_str()),
377  std::bitset<kNumBits>(bit_strings[1].c_str()),
378  std::bitset<kNumBits>(bit_strings[2].c_str()),
379  std::bitset<kNumBits>(bit_strings[3].c_str()),
380  std::bitset<kNumBits>(bit_strings[4].c_str()),
381  std::bitset<kNumBits>(bit_strings[5].c_str())}));
382 } // namespace
383 
384 template <typename T>
385 class HashValueSequenceTest : public testing::Test {
386 };
387 TYPED_TEST_SUITE_P(HashValueSequenceTest);
388 
389 TYPED_TEST_P(HashValueSequenceTest, BasicUsage) {
391 
392  using ValueType = typename TypeParam::value_type;
393  auto a = static_cast<ValueType>(0);
394  auto b = static_cast<ValueType>(23);
395  auto c = static_cast<ValueType>(42);
396 
398  std::make_tuple(TypeParam(), TypeParam{}, TypeParam{a, b, c},
399  TypeParam{a, b}, TypeParam{b, c})));
400 }
401 
402 REGISTER_TYPED_TEST_CASE_P(HashValueSequenceTest, BasicUsage);
403 using IntSequenceTypes =
404  testing::Types<std::deque<int>, std::forward_list<int>, std::list<int>,
405  std::vector<int>, std::vector<bool>, std::set<int>,
406  std::multiset<int>>;
407 INSTANTIATE_TYPED_TEST_CASE_P(My, HashValueSequenceTest, IntSequenceTypes);
408 
409 // Private type that only supports AbslHashValue to make sure our chosen hash
410 // implementation is recursive within absl::Hash.
411 // It uses std::abs() on the value to provide different bitwise representations
412 // of the same logical value.
413 struct Private {
414  int i;
415  template <typename H>
416  friend H AbslHashValue(H h, Private p) {
417  return H::combine(std::move(h), std::abs(p.i));
418  }
419 
420  friend bool operator==(Private a, Private b) {
421  return std::abs(a.i) == std::abs(b.i);
422  }
423 
424  friend std::ostream& operator<<(std::ostream& o, Private p) {
425  return o << p.i;
426  }
427 };
428 
429 // Test helper for combine_piecewise_buffer. It holds a string_view to the
430 // buffer-to-be-hashed. Its AbslHashValue specialization will split up its
431 // contents at the character offsets requested.
432 class PiecewiseHashTester {
433  public:
434  // Create a hash view of a buffer to be hashed contiguously.
435  explicit PiecewiseHashTester(absl::string_view buf)
436  : buf_(buf), piecewise_(false), split_locations_() {}
437 
438  // Create a hash view of a buffer to be hashed piecewise, with breaks at the
439  // given locations.
440  PiecewiseHashTester(absl::string_view buf, std::set<size_t> split_locations)
441  : buf_(buf),
442  piecewise_(true),
443  split_locations_(std::move(split_locations)) {}
444 
445  template <typename H>
446  friend H AbslHashValue(H h, const PiecewiseHashTester& p) {
447  if (!p.piecewise_) {
448  return H::combine_contiguous(std::move(h), p.buf_.data(), p.buf_.size());
449  }
451  if (p.split_locations_.empty()) {
452  h = combiner.add_buffer(std::move(h), p.buf_.data(), p.buf_.size());
453  return combiner.finalize(std::move(h));
454  }
455  size_t begin = 0;
456  for (size_t next : p.split_locations_) {
457  absl::string_view chunk = p.buf_.substr(begin, next - begin);
458  h = combiner.add_buffer(std::move(h), chunk.data(), chunk.size());
459  begin = next;
460  }
461  absl::string_view last_chunk = p.buf_.substr(begin);
462  if (!last_chunk.empty()) {
463  h = combiner.add_buffer(std::move(h), last_chunk.data(),
464  last_chunk.size());
465  }
466  return combiner.finalize(std::move(h));
467  }
468 
469  private:
471  bool piecewise_;
472  std::set<size_t> split_locations_;
473 };
474 
475 // Dummy object that hashes as two distinct contiguous buffers, "foo" followed
476 // by "bar"
477 struct DummyFooBar {
478  template <typename H>
479  friend H AbslHashValue(H h, const DummyFooBar&) {
480  const char* foo = "foo";
481  const char* bar = "bar";
482  h = H::combine_contiguous(std::move(h), foo, 3);
483  h = H::combine_contiguous(std::move(h), bar, 3);
484  return h;
485  }
486 };
487 
488 TEST(HashValueTest, CombinePiecewiseBuffer) {
490 
491  // Check that hashing an empty buffer through the piecewise API works.
492  EXPECT_EQ(hash(PiecewiseHashTester("")), hash(PiecewiseHashTester("", {})));
493 
494  // Similarly, small buffers should give consistent results
495  EXPECT_EQ(hash(PiecewiseHashTester("foobar")),
496  hash(PiecewiseHashTester("foobar", {})));
497  EXPECT_EQ(hash(PiecewiseHashTester("foobar")),
498  hash(PiecewiseHashTester("foobar", {3})));
499 
500  // But hashing "foobar" in pieces gives a different answer than hashing "foo"
501  // contiguously, then "bar" contiguously.
502  EXPECT_NE(hash(PiecewiseHashTester("foobar", {3})),
503  absl::Hash<DummyFooBar>()(DummyFooBar{}));
504 
505  // Test hashing a large buffer incrementally, broken up in several different
506  // ways. Arrange for breaks on and near the stride boundaries to look for
507  // off-by-one errors in the implementation.
508  //
509  // This test is run on a buffer that is a multiple of the stride size, and one
510  // that isn't.
511  for (size_t big_buffer_size : {1024 * 2 + 512, 1024 * 3}) {
512  SCOPED_TRACE(big_buffer_size);
513  std::string big_buffer;
514  for (int i = 0; i < big_buffer_size; ++i) {
515  // Arbitrary string
516  big_buffer.push_back(32 + (i * (i / 3)) % 64);
517  }
518  auto big_buffer_hash = hash(PiecewiseHashTester(big_buffer));
519 
520  const int possible_breaks = 9;
521  size_t breaks[possible_breaks] = {1, 512, 1023, 1024, 1025,
522  1536, 2047, 2048, 2049};
523  for (unsigned test_mask = 0; test_mask < (1u << possible_breaks);
524  ++test_mask) {
525  SCOPED_TRACE(test_mask);
526  std::set<size_t> break_locations;
527  for (int j = 0; j < possible_breaks; ++j) {
528  if (test_mask & (1u << j)) {
529  break_locations.insert(breaks[j]);
530  }
531  }
532  EXPECT_EQ(
533  hash(PiecewiseHashTester(big_buffer, std::move(break_locations))),
534  big_buffer_hash);
535  }
536  }
537 }
538 
539 TEST(HashValueTest, PrivateSanity) {
540  // Sanity check that Private is working as the tests below expect it to work.
542  EXPECT_NE(SpyHash(Private{0}), SpyHash(Private{1}));
543  EXPECT_EQ(SpyHash(Private{1}), SpyHash(Private{1}));
544 }
545 
546 TEST(HashValueTest, Optional) {
548 
549  using O = absl::optional<Private>;
551  std::make_tuple(O{}, O{{1}}, O{{-1}}, O{{10}})));
552 }
553 
554 TEST(HashValueTest, Variant) {
557 
559  V(Private{1}), V(Private{-1}), V(Private{2}), V("ABC"), V("BCD"))));
560 
561 #if ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
562  struct S {};
563  EXPECT_FALSE(is_hashable<absl::variant<S>>::value);
564 #endif
565 }
566 
567 TEST(HashValueTest, Maps) {
568  EXPECT_TRUE((is_hashable<std::map<int, std::string>>::value));
569 
570  using M = std::map<int, std::string>;
572  M{}, M{{0, "foo"}}, M{{1, "foo"}}, M{{0, "bar"}}, M{{1, "bar"}},
573  M{{0, "foo"}, {42, "bar"}}, M{{1, "foo"}, {42, "bar"}},
574  M{{1, "foo"}, {43, "bar"}}, M{{1, "foo"}, {43, "baz"}})));
575 
576  using MM = std::multimap<int, std::string>;
578  MM{}, MM{{0, "foo"}}, MM{{1, "foo"}}, MM{{0, "bar"}}, MM{{1, "bar"}},
579  MM{{0, "foo"}, {0, "bar"}}, MM{{0, "bar"}, {0, "foo"}},
580  MM{{0, "foo"}, {42, "bar"}}, MM{{1, "foo"}, {42, "bar"}},
581  MM{{1, "foo"}, {1, "foo"}, {43, "bar"}}, MM{{1, "foo"}, {43, "baz"}})));
582 }
583 
584 TEST(HashValueTest, ReferenceWrapper) {
585  EXPECT_TRUE(is_hashable<std::reference_wrapper<Private>>::value);
586 
587  Private p1{1}, p10{10};
589  p1, p10, std::ref(p1), std::ref(p10), std::cref(p1), std::cref(p10))));
590 
591  EXPECT_TRUE(is_hashable<std::reference_wrapper<int>>::value);
592  int one = 1, ten = 10;
594  one, ten, std::ref(one), std::ref(ten), std::cref(one), std::cref(ten))));
595 
597  std::make_tuple(std::tuple<std::reference_wrapper<int>>(std::ref(one)),
598  std::tuple<std::reference_wrapper<int>>(std::ref(ten)),
599  std::tuple<int>(one), std::tuple<int>(ten))));
600 }
601 
602 template <typename T, typename = void>
603 struct IsHashCallable : std::false_type {};
604 
605 template <typename T>
606 struct IsHashCallable<T, absl::void_t<decltype(std::declval<absl::Hash<T>>()(
607  std::declval<const T&>()))>> : std::true_type {};
608 
609 template <typename T, typename = void>
610 struct IsAggregateInitializable : std::false_type {};
611 
612 template <typename T>
613 struct IsAggregateInitializable<T, absl::void_t<decltype(T{})>>
614  : std::true_type {};
615 
616 TEST(IsHashableTest, ValidHash) {
618  EXPECT_TRUE(std::is_default_constructible<absl::Hash<int>>::value);
619  EXPECT_TRUE(std::is_copy_constructible<absl::Hash<int>>::value);
620  EXPECT_TRUE(std::is_move_constructible<absl::Hash<int>>::value);
624  EXPECT_TRUE(IsAggregateInitializable<absl::Hash<int>>::value);
625 }
626 
627 #if ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
628 TEST(IsHashableTest, PoisonHash) {
629  struct X {};
631  EXPECT_FALSE(std::is_default_constructible<absl::Hash<X>>::value);
632  EXPECT_FALSE(std::is_copy_constructible<absl::Hash<X>>::value);
633  EXPECT_FALSE(std::is_move_constructible<absl::Hash<X>>::value);
637 #if !defined(__GNUC__) || __GNUC__ < 9
638  // This doesn't compile on GCC 9.
639  EXPECT_FALSE(IsAggregateInitializable<absl::Hash<X>>::value);
640 #endif
641 }
642 #endif // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
643 
644 // Hashable types
645 //
646 // These types exist simply to exercise various AbslHashValue behaviors, so
647 // they are named by what their AbslHashValue overload does.
648 struct NoOp {
649  template <typename HashCode>
650  friend HashCode AbslHashValue(HashCode h, NoOp n) {
651  return h;
652  }
653 };
654 
655 struct EmptyCombine {
656  template <typename HashCode>
657  friend HashCode AbslHashValue(HashCode h, EmptyCombine e) {
658  return HashCode::combine(std::move(h));
659  }
660 };
661 
662 template <typename Int>
663 struct CombineIterative {
664  template <typename HashCode>
665  friend HashCode AbslHashValue(HashCode h, CombineIterative c) {
666  for (int i = 0; i < 5; ++i) {
667  h = HashCode::combine(std::move(h), Int(i));
668  }
669  return h;
670  }
671 };
672 
673 template <typename Int>
674 struct CombineVariadic {
675  template <typename HashCode>
676  friend HashCode AbslHashValue(HashCode h, CombineVariadic c) {
677  return HashCode::combine(std::move(h), Int(0), Int(1), Int(2), Int(3),
678  Int(4));
679  }
680 };
681 enum class InvokeTag {
682  kUniquelyRepresented,
683  kHashValue,
684 #if ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
685  kLegacyHash,
686 #endif // ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
687  kStdHash,
688  kNone
689 };
690 
691 template <InvokeTag T>
692 using InvokeTagConstant = std::integral_constant<InvokeTag, T>;
693 
694 template <InvokeTag... Tags>
695 struct MinTag;
696 
697 template <InvokeTag a, InvokeTag b, InvokeTag... Tags>
698 struct MinTag<a, b, Tags...> : MinTag<(a < b ? a : b), Tags...> {};
699 
700 template <InvokeTag a>
701 struct MinTag<a> : InvokeTagConstant<a> {};
702 
703 template <InvokeTag... Tags>
704 struct CustomHashType {
705  explicit CustomHashType(size_t val) : value(val) {}
706  size_t value;
707 };
708 
709 template <InvokeTag allowed, InvokeTag... tags>
710 struct EnableIfContained
711  : std::enable_if<absl::disjunction<
712  std::integral_constant<bool, allowed == tags>...>::value> {};
713 
714 template <
715  typename H, InvokeTag... Tags,
716  typename = typename EnableIfContained<InvokeTag::kHashValue, Tags...>::type>
717 H AbslHashValue(H state, CustomHashType<Tags...> t) {
718  static_assert(MinTag<Tags...>::value == InvokeTag::kHashValue, "");
719  return H::combine(std::move(state),
720  t.value + static_cast<int>(InvokeTag::kHashValue));
721 }
722 
723 } // namespace
724 
725 namespace absl {
726 ABSL_NAMESPACE_BEGIN
727 namespace hash_internal {
728 template <InvokeTag... Tags>
729 struct is_uniquely_represented<
730  CustomHashType<Tags...>,
731  typename EnableIfContained<InvokeTag::kUniquelyRepresented, Tags...>::type>
732  : std::true_type {};
733 } // namespace hash_internal
734 ABSL_NAMESPACE_END
735 } // namespace absl
736 
737 #if ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
738 namespace ABSL_INTERNAL_LEGACY_HASH_NAMESPACE {
739 template <InvokeTag... Tags>
740 struct hash<CustomHashType<Tags...>> {
741  template <InvokeTag... TagsIn, typename = typename EnableIfContained<
742  InvokeTag::kLegacyHash, TagsIn...>::type>
743  size_t operator()(CustomHashType<TagsIn...> t) const {
744  static_assert(MinTag<Tags...>::value == InvokeTag::kLegacyHash, "");
745  return t.value + static_cast<int>(InvokeTag::kLegacyHash);
746  }
747 };
748 } // namespace ABSL_INTERNAL_LEGACY_HASH_NAMESPACE
749 #endif // ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
750 
751 namespace std {
752 template <InvokeTag... Tags> // NOLINT
753 struct hash<CustomHashType<Tags...>> {
754  template <InvokeTag... TagsIn, typename = typename EnableIfContained<
755  InvokeTag::kStdHash, TagsIn...>::type>
756  size_t operator()(CustomHashType<TagsIn...> t) const {
757  static_assert(MinTag<Tags...>::value == InvokeTag::kStdHash, "");
758  return t.value + static_cast<int>(InvokeTag::kStdHash);
759  }
760 };
761 } // namespace std
762 
763 namespace {
764 
765 template <typename... T>
766 void TestCustomHashType(InvokeTagConstant<InvokeTag::kNone>, T...) {
767  using type = CustomHashType<T::value...>;
768  SCOPED_TRACE(testing::PrintToString(std::vector<InvokeTag>{T::value...}));
769  EXPECT_TRUE(is_hashable<type>());
770  EXPECT_TRUE(is_hashable<const type>());
771  EXPECT_TRUE(is_hashable<const type&>());
772 
773  const size_t offset = static_cast<int>(std::min({T::value...}));
774  EXPECT_EQ(SpyHash(type(7)), SpyHash(size_t{7 + offset}));
775 }
776 
777 void TestCustomHashType(InvokeTagConstant<InvokeTag::kNone>) {
778 #if ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
779  // is_hashable is false if we don't support any of the hooks.
780  using type = CustomHashType<>;
781  EXPECT_FALSE(is_hashable<type>());
782  EXPECT_FALSE(is_hashable<const type>());
783  EXPECT_FALSE(is_hashable<const type&>());
784 #endif // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
785 }
786 
787 template <InvokeTag Tag, typename... T>
788 void TestCustomHashType(InvokeTagConstant<Tag> tag, T... t) {
789  constexpr auto next = static_cast<InvokeTag>(static_cast<int>(Tag) + 1);
790  TestCustomHashType(InvokeTagConstant<next>(), tag, t...);
791  TestCustomHashType(InvokeTagConstant<next>(), t...);
792 }
793 
794 TEST(HashTest, CustomHashType) {
795  TestCustomHashType(InvokeTagConstant<InvokeTag{}>());
796 }
797 
798 TEST(HashTest, NoOpsAreEquivalent) {
799  EXPECT_EQ(Hash<NoOp>()({}), Hash<NoOp>()({}));
800  EXPECT_EQ(Hash<NoOp>()({}), Hash<EmptyCombine>()({}));
801 }
802 
803 template <typename T>
804 class HashIntTest : public testing::Test {
805 };
806 TYPED_TEST_SUITE_P(HashIntTest);
807 
808 TYPED_TEST_P(HashIntTest, BasicUsage) {
809  EXPECT_NE(Hash<NoOp>()({}), Hash<TypeParam>()(0));
810  EXPECT_NE(Hash<NoOp>()({}),
811  Hash<TypeParam>()(std::numeric_limits<TypeParam>::max()));
812  if (std::numeric_limits<TypeParam>::min() != 0) {
813  EXPECT_NE(Hash<NoOp>()({}),
814  Hash<TypeParam>()(std::numeric_limits<TypeParam>::min()));
815  }
816 
817  EXPECT_EQ(Hash<CombineIterative<TypeParam>>()({}),
818  Hash<CombineVariadic<TypeParam>>()({}));
819 }
820 
821 REGISTER_TYPED_TEST_CASE_P(HashIntTest, BasicUsage);
822 using IntTypes = testing::Types<unsigned char, char, int, int32_t, int64_t,
823  uint32_t, uint64_t, size_t>;
824 INSTANTIATE_TYPED_TEST_CASE_P(My, HashIntTest, IntTypes);
825 
826 struct StructWithPadding {
827  char c;
828  int i;
829 
830  template <typename H>
831  friend H AbslHashValue(H hash_state, const StructWithPadding& s) {
832  return H::combine(std::move(hash_state), s.c, s.i);
833  }
834 };
835 
836 static_assert(sizeof(StructWithPadding) > sizeof(char) + sizeof(int),
837  "StructWithPadding doesn't have padding");
838 static_assert(std::is_standard_layout<StructWithPadding>::value, "");
839 
840 // This check has to be disabled because libstdc++ doesn't support it.
841 // static_assert(std::is_trivially_constructible<StructWithPadding>::value, "");
842 
843 template <typename T>
844 struct ArraySlice {
845  T* begin;
846  T* end;
847 
848  template <typename H>
849  friend H AbslHashValue(H hash_state, const ArraySlice& slice) {
850  for (auto t = slice.begin; t != slice.end; ++t) {
851  hash_state = H::combine(std::move(hash_state), *t);
852  }
853  return hash_state;
854  }
855 };
856 
857 TEST(HashTest, HashNonUniquelyRepresentedType) {
858  // Create equal StructWithPadding objects that are known to have non-equal
859  // padding bytes.
860  static const size_t kNumStructs = 10;
861  unsigned char buffer1[kNumStructs * sizeof(StructWithPadding)];
862  std::memset(buffer1, 0, sizeof(buffer1));
863  auto* s1 = reinterpret_cast<StructWithPadding*>(buffer1);
864 
865  unsigned char buffer2[kNumStructs * sizeof(StructWithPadding)];
866  std::memset(buffer2, 255, sizeof(buffer2));
867  auto* s2 = reinterpret_cast<StructWithPadding*>(buffer2);
868  for (int i = 0; i < kNumStructs; ++i) {
869  SCOPED_TRACE(i);
870  s1[i].c = s2[i].c = '0' + i;
871  s1[i].i = s2[i].i = i;
872  ASSERT_FALSE(memcmp(buffer1 + i * sizeof(StructWithPadding),
873  buffer2 + i * sizeof(StructWithPadding),
874  sizeof(StructWithPadding)) == 0)
875  << "Bug in test code: objects do not have unequal"
876  << " object representations";
877  }
878 
880  EXPECT_EQ(Hash<ArraySlice<StructWithPadding>>()({s1, s1 + kNumStructs}),
881  Hash<ArraySlice<StructWithPadding>>()({s2, s2 + kNumStructs}));
882 }
883 
884 TEST(HashTest, StandardHashContainerUsage) {
885  std::unordered_map<int, std::string, Hash<int>> map = {{0, "foo"},
886  {42, "bar"}};
887 
888  EXPECT_NE(map.find(0), map.end());
889  EXPECT_EQ(map.find(1), map.end());
890  EXPECT_NE(map.find(0u), map.end());
891 }
892 
893 struct ConvertibleFromNoOp {
894  ConvertibleFromNoOp(NoOp) {} // NOLINT(runtime/explicit)
895 
896  template <typename H>
897  friend H AbslHashValue(H hash_state, ConvertibleFromNoOp) {
898  return H::combine(std::move(hash_state), 1);
899  }
900 };
901 
902 TEST(HashTest, HeterogeneousCall) {
904  Hash<NoOp>()(NoOp()));
905 }
906 
907 TEST(IsUniquelyRepresentedTest, SanityTest) {
909 
914 }
915 
916 struct IntAndString {
917  int i;
918  std::string s;
919 
920  template <typename H>
921  friend H AbslHashValue(H hash_state, IntAndString int_and_string) {
922  return H::combine(std::move(hash_state), int_and_string.s,
923  int_and_string.i);
924  }
925 };
926 
927 TEST(HashTest, SmallValueOn64ByteBoundary) {
928  Hash<IntAndString>()(IntAndString{0, std::string(63, '0')});
929 }
930 
931 struct TypeErased {
932  size_t n;
933 
934  template <typename H>
935  friend H AbslHashValue(H hash_state, const TypeErased& v) {
936  v.HashValue(absl::HashState::Create(&hash_state));
937  return hash_state;
938  }
939 
940  void HashValue(absl::HashState state) const {
942  }
943 };
944 
945 TEST(HashTest, TypeErased) {
947  EXPECT_TRUE((is_hashable<std::pair<TypeErased, int>>::value));
948 
949  EXPECT_EQ(SpyHash(TypeErased{7}), SpyHash(size_t{7}));
950  EXPECT_NE(SpyHash(TypeErased{7}), SpyHash(size_t{13}));
951 
952  EXPECT_EQ(SpyHash(std::make_pair(TypeErased{7}, 17)),
953  SpyHash(std::make_pair(size_t{7}, 17)));
954 }
955 
956 struct ValueWithBoolConversion {
957  operator bool() const { return false; }
958  int i;
959 };
960 
961 } // namespace
962 namespace std {
963 template <>
964 struct hash<ValueWithBoolConversion> {
965  size_t operator()(ValueWithBoolConversion v) { return v.i; }
966 };
967 } // namespace std
968 
969 namespace {
970 
971 TEST(HashTest, DoesNotUseImplicitConversionsToBool) {
972  EXPECT_NE(absl::Hash<ValueWithBoolConversion>()(ValueWithBoolConversion{0}),
973  absl::Hash<ValueWithBoolConversion>()(ValueWithBoolConversion{1}));
974 }
975 
976 } // namespace
TYPED_TEST_P
#define TYPED_TEST_P(SuiteName, TestName)
Definition: googletest/googletest/include/gtest/gtest-typed-test.h:270
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
absl::Cord
Definition: abseil-cpp/absl/strings/cord.h:150
absl::debugging_internal::Optional
static bool Optional(bool)
Definition: abseil-cpp/absl/debugging/internal/demangle.cc:333
absl::AbslHashValue
H AbslHashValue(H h, const absl::InlinedVector< T, N, A > &a)
Definition: abseil-cpp/absl/container/inlined_vector.h:858
absl::HashState::Create
static HashState Create(T *state)
Definition: abseil-cpp/absl/hash/hash.h:321
Hash
Hash
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:339
REGISTER_TYPED_TEST_CASE_P
#define REGISTER_TYPED_TEST_CASE_P
Definition: googletest/googletest/include/gtest/gtest-typed-test.h:300
absl::str_format_internal::LengthMod::j
@ j
absl::VerifyTypeImplementsAbslHashCorrectly
ABSL_NAMESPACE_BEGIN ABSL_MUST_USE_RESULT testing::AssertionResult VerifyTypeImplementsAbslHashCorrectly(const Container &values)
Definition: abseil-cpp/absl/hash/hash_testing.h:345
grpc_event_engine::experimental::slice_detail::operator==
bool operator==(const BaseSlice &a, const BaseSlice &b)
Definition: include/grpc/event_engine/slice.h:117
absl::hash_internal::Hash
Definition: abseil-cpp/absl/hash/internal/hash.h:1221
X
#define X(c)
bool
bool
Definition: setup_once.h:312
memset
return memset(p, 0, total)
S
#define S(s)
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
false
#define false
Definition: setup_once.h:323
std::tr1::make_tuple
tuple make_tuple()
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:1619
NoOp
Definition: bm_call_create.cc:477
large
int large
Definition: bloaty/third_party/zlib/examples/enough.c:172
bar
Definition: bloaty/third_party/googletest/googletest/test/googletest-output-test_.cc:562
google::protobuf.internal::true_type
integral_constant< bool, true > true_type
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:89
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
google::protobuf.internal::false_type
integral_constant< bool, false > false_type
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:90
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
u
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:351
absl::hash_internal::is_uniquely_represented
Definition: abseil-cpp/absl/hash/internal/hash.h:296
foo
Definition: bloaty/third_party/googletest/googletest/test/googletest-output-test_.cc:546
absl::hash_internal::HashStateBase< HashState >::combine
static HashState combine(HashState state, const T &value, const Ts &... values)
Definition: abseil-cpp/absl/hash/internal/hash.h:1226
absl::FormatConversionChar::s
@ s
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
ASSERT_LE
#define ASSERT_LE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2064
xds_manager.p
p
Definition: xds_manager.py:60
absl::flags_internal::HelpMode::kNone
@ kNone
absl::container_internal::hash_internal::EnumClass
EnumClass
Definition: abseil-cpp/absl/container/internal/hash_generator_testing.h:58
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
T
#define T(upbtypeconst, upbtype, ctype, default_value)
gen_build_yaml.struct
def struct(**kwargs)
Definition: test/core/end2end/gen_build_yaml.py:30
true
#define true
Definition: setup_once.h:324
testing::Test
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:402
FragmentedCord
absl::Cord FragmentedCord(size_t size)
Definition: abseil-cpp/absl/hash/hash_benchmark.cc:94
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
hash
uint64_t hash
Definition: ring_hash.cc:284
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
testing::internal::ProxyTypeList
Definition: googletest/googletest/include/gtest/internal/gtest-type-util.h:155
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
SCOPED_TRACE
#define SCOPED_TRACE(message)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2264
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
xds_interop_client.int
int
Definition: xds_interop_client.py:113
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
absl::hash_internal::PiecewiseCombiner::add_buffer
H add_buffer(H state, const unsigned char *data, size_t size)
Definition: abseil-cpp/absl/hash/internal/hash.h:1249
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
absl::string_view::size
constexpr size_type size() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:277
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
TEST
#define TEST(name, init_size,...)
Definition: arena_test.cc:75
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
absl::random_internal_nanobenchmark::Func
FuncOutput(*)(const void *, FuncInput) Func
Definition: abseil-cpp/absl/random/internal/nanobenchmark.h:68
FlatCord
absl::Cord FlatCord(size_t size)
Definition: abseil-cpp/absl/hash/hash_benchmark.cc:88
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
absl::optional
Definition: abseil-cpp/absl/types/internal/optional.h:61
absl::inlined_vector_internal::Pointer
typename AllocatorTraits< A >::pointer Pointer
Definition: abseil-cpp/absl/container/internal/inlined_vector.h:52
ref
unsigned ref
Definition: cxa_demangle.cpp:4909
absl::compare_internal::value_type
int8_t value_type
Definition: abseil-cpp/absl/types/compare.h:45
buf_
char buf_[N]
Definition: cxa_demangle.cpp:4722
testing::internal::wstring
::std::wstring wstring
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:887
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
min
#define min(a, b)
Definition: qsort.h:83
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
Json::Int
int Int
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:228
d
static const fe d
Definition: curve25519_tables.h:19
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
Json::ValueType
ValueType
Type of the value held by a Value object.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:463
H
#define H(b, c, d)
Definition: md4.c:114
value
const char * value
Definition: hpack_parser_table.cc:165
TYPED_TEST_SUITE_P
#define TYPED_TEST_SUITE_P(SuiteName)
Definition: googletest/googletest/include/gtest/gtest-typed-test.h:259
absl::void_t
typename type_traits_internal::VoidTImpl< Ts... >::type void_t
Definition: abseil-cpp/absl/meta/type_traits.h:218
absl::time_internal::cctz::detail::align
CONSTEXPR_F fields align(second_tag, fields f) noexcept
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h:325
std::hash< ValueWithBoolConversion >::operator()
size_t operator()(ValueWithBoolConversion v)
Definition: bloaty/third_party/abseil-cpp/absl/hash/hash_test.cc:965
absl::hash_internal::SpyHashState
SpyHashStateImpl< void > SpyHashState
Definition: abseil-cpp/absl/hash/internal/spy_hash_state.h:260
absl::str_format_internal::LengthMod::t
@ t
next
AllocList * next[kMaxLevel]
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:100
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
INSTANTIATE_TYPED_TEST_CASE_P
#define INSTANTIATE_TYPED_TEST_CASE_P
Definition: googletest/googletest/include/gtest/gtest-typed-test.h:325
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
ASSERT_FALSE
#define ASSERT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1976
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
absl::is_copy_assignable
Definition: abseil-cpp/absl/meta/type_traits.h:194
absl::hash_internal::PiecewiseCombiner::finalize
H finalize(H state)
Definition: abseil-cpp/absl/hash/internal/hash.h:1282
testing::internal::Strings
::std::vector< ::std::string > Strings
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-printers.h:872
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
absl::MakeFragmentedCord
Cord MakeFragmentedCord(const Container &c)
Definition: abseil-cpp/absl/strings/cord_test_helpers.h:103
absl::string_view::empty
constexpr bool empty() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:292
absl::is_move_assignable
Definition: abseil-cpp/absl/meta/type_traits.h:199
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
setup.template
template
Definition: setup.py:47
grpc::operator<<
std::ostream & operator<<(std::ostream &out, const string_ref &string)
Definition: grpcpp/impl/codegen/string_ref.h:145
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
absl::variant
Definition: abseil-cpp/absl/types/internal/variant.h:46
absl::string_view::data
constexpr const_pointer data() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:336
absl::str_format_internal::LengthMod::h
@ h
absl::string_view::substr
constexpr string_view substr(size_type pos=0, size_type n=npos) const
Definition: abseil-cpp/absl/strings/string_view.h:399
absl::HashState
Definition: abseil-cpp/absl/hash/hash.h:312
absl::hash_internal::PiecewiseCombiner
Definition: abseil-cpp/absl/hash/internal/hash.h:89
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
absl::Hash
absl::hash_internal::Hash< T > Hash
Definition: abseil-cpp/absl/hash/hash.h:247


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:01