From 18045c4e32cbe6217224f46261b9e2607d6e723d Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 25 May 2021 13:13:33 -0700 Subject: Export of internal Abseil changes -- d74f30ef0da7139c30a24eb6c1776bc0c257e642 by Derek Mauro : Internal change PiperOrigin-RevId: 375779441 -- 25e33cde30d78dbafcb81ee3ce77c3d70c74db5a by Abseil Team : Internal change PiperOrigin-RevId: 375520720 -- 46857d17d4dbc6fbd13a27dd82e14ec814dd117a by Samuel Benzaquen : Add an explicit template parameter barrier to absl::HashOf. PiperOrigin-RevId: 375103300 -- cf2bf52b9a425b0360ed1f46778f0ef1326a3658 by Abseil Team : 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 : 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 --- absl/hash/hash.h | 2 +- absl/hash/hash_test.cc | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'absl/hash') 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; // 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 +template size_t HashOf(const Types&... values) { auto tuple = std::tie(values...); return absl::Hash{}(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 +std::true_type HashOfExplicitParameter(decltype(absl::HashOf(0))) { + return {}; +} +template +std::false_type HashOfExplicitParameter(size_t) { + return {}; +} + +TEST(HashOf, CantPassExplicitTemplateParameters) { + EXPECT_FALSE(HashOfExplicitParameter(0)); +} + } // namespace -- cgit v1.2.3