diff options
author | Abseil Team <absl-team@google.com> | 2021-05-25 13:13:33 -0700 |
---|---|---|
committer | Dino Radaković <dinor@google.com> | 2021-05-25 13:18:25 -0700 |
commit | 18045c4e32cbe6217224f46261b9e2607d6e723d (patch) | |
tree | 79e3a874888d298b317e4111e342815a30272577 /absl/hash | |
parent | 7e8ec214f2ceb949ad8ad33d83c194de3028ae55 (diff) |
Export of internal Abseil changes
--
d74f30ef0da7139c30a24eb6c1776bc0c257e642 by Derek Mauro <dmauro@google.com>:
Internal change
PiperOrigin-RevId: 375779441
--
25e33cde30d78dbafcb81ee3ce77c3d70c74db5a by Abseil Team <absl-team@google.com>:
Internal change
PiperOrigin-RevId: 375520720
--
46857d17d4dbc6fbd13a27dd82e14ec814dd117a by Samuel Benzaquen <sbenza@google.com>:
Add an explicit template parameter barrier to absl::HashOf.
PiperOrigin-RevId: 375103300
--
cf2bf52b9a425b0360ed1f46778f0ef1326a3658 by Abseil Team <absl-team@google.com>:
Improve string_view API compliance with C++17 std::basic_string_view.
This adds missing overloads, default values, and constexpr specifiers.
PiperOrigin-RevId: 374885658
--
41e55166dc5bd3ed7bce567c400781585d55e1ce by Derek Mauro <dmauro@google.com>:
Update CI to GCC 11.1, Bazel 4.0.0, CMake 3.20.2, and
LLVM git:7bcc0a1e399d461af7ec013ff33bc330a2de6641
PiperOrigin-RevId: 374858288
GitOrigin-RevId: d74f30ef0da7139c30a24eb6c1776bc0c257e642
Change-Id: I657c815c83522b030495ff54ca327e7012ed151e
Diffstat (limited to 'absl/hash')
-rw-r--r-- | absl/hash/hash.h | 2 | ||||
-rw-r--r-- | absl/hash/hash_test.cc | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/absl/hash/hash.h b/absl/hash/hash.h index 69c44fde..8282ea53 100644 --- a/absl/hash/hash.h +++ b/absl/hash/hash.h @@ -230,7 +230,7 @@ using Hash = absl::hash_internal::Hash<T>; // The requirement that the arguments match in both type and value is critical. // It means that `a == b` does not necessarily imply `HashOf(a) == HashOf(b)` if // `a` and `b` have different types. For example, `HashOf(2) != HashOf(2.0)`. -template <typename... Types> +template <int&... ExplicitArgumentBarrier, typename... Types> size_t HashOf(const Types&... values) { auto tuple = std::tie(values...); return absl::Hash<decltype(tuple)>{}(tuple); diff --git a/absl/hash/hash_test.cc b/absl/hash/hash_test.cc index 02b7733d..b3ddebdd 100644 --- a/absl/hash/hash_test.cc +++ b/absl/hash/hash_test.cc @@ -995,4 +995,17 @@ TEST(HashOf, MatchesHashOfTupleForMultipleArguments) { absl::HashOf(std::make_tuple(hello, world))); } +template <typename T> +std::true_type HashOfExplicitParameter(decltype(absl::HashOf<T>(0))) { + return {}; +} +template <typename T> +std::false_type HashOfExplicitParameter(size_t) { + return {}; +} + +TEST(HashOf, CantPassExplicitTemplateParameters) { + EXPECT_FALSE(HashOfExplicitParameter<int>(0)); +} + } // namespace |