about summary refs log tree commit diff
path: root/absl/types/any.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-08-19T17·27-0700
committerXiaoyi Zhang <zhangxy@google.com>2019-08-19T19·34-0400
commit0e7afdcbd24c7e5b7cab4e0217d8886f1525b520 (patch)
tree4f01b59581a9ecfd7e3bb833d609ab53fbe50e19 /absl/types/any.h
parent9a41ffdd3a0ccbcdd29c4e3886b28e06f2cd9c66 (diff)
Export of internal Abseil changes
--
62058c9c008e23c787f35c1a5fe05851046a71f1 by Abseil Team <absl-team@google.com>:

Fix some strange usage of INSTANTIATE_TEST_SUITE_P

PiperOrigin-RevId: 264185105

--
4400d84027d86415a2f9b81996ff22e7fd7aa30f by Derek Mauro <dmauro@google.com>:

Disable testing std::string_view from nullptr on GCC >= GCC9.

PiperOrigin-RevId: 264150587

--
656d5a742ba48d025589709fad33ddae4b02c620 by Matt Calabrese <calabrese@google.com>:

Fix `absl::any_cast` such that it properly works with qualifications.

PiperOrigin-RevId: 263843429

--
6ec89214a4ef2170bf069623a56ffd22863b748d by Abseil Team <absl-team@google.com>:

Use macros to enable inline constexpr variables in compare.h when the compiler supports the feature.

PiperOrigin-RevId: 263790677

--
a5171e0897195a0367fc08abce9504f813d027ff by Derek Mauro <dmauro@google.com>:

Add the Apache License to files that are missing it.

PiperOrigin-RevId: 263774164

--
19e09a7ce8a0aac0a7d534e1799e4d73b63a1bb5 by Abseil Team <absl-team@google.com>:

Update iter.position when moving up the tree in rebalance_after_delete.

This field isn't read after the first iteration in rebalance_after_delete, and I think it's not a correctness issue, but it is read in try_merge_or_rebalance and potentially affects rebalancing decisions so it can affect performance. There's also an extremely unlikely potential for undefined behavior due to signed integer overflow since this field is only ever incremented in try_merge_or_rebalance (and position is an int). Basically though, I just don't think it makes sense to have this invalid iterator floating around here.

PiperOrigin-RevId: 263770305
GitOrigin-RevId: 62058c9c008e23c787f35c1a5fe05851046a71f1
Change-Id: I1e2fb7cbfac7507dddedd181414ee35a5778f8f5
Diffstat (limited to 'absl/types/any.h')
-rw-r--r--absl/types/any.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/absl/types/any.h b/absl/types/any.h
index f3a32812662f..d2e2533f05bc 100644
--- a/absl/types/any.h
+++ b/absl/types/any.h
@@ -515,18 +515,22 @@ ValueType any_cast(any&& operand) {
 // Description at the declaration site (top of file).
 template <typename T>
 const T* any_cast(const any* operand) noexcept {
-  return operand && operand->GetObjTypeId() == any::IdForType<T>()
+  using U =
+      typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+  return operand && operand->GetObjTypeId() == any::IdForType<U>()
              ? std::addressof(
-                   static_cast<const any::Obj<T>*>(operand->obj_.get())->value)
+                   static_cast<const any::Obj<U>*>(operand->obj_.get())->value)
              : nullptr;
 }
 
 // Description at the declaration site (top of file).
 template <typename T>
 T* any_cast(any* operand) noexcept {
-  return operand && operand->GetObjTypeId() == any::IdForType<T>()
+  using U =
+      typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+  return operand && operand->GetObjTypeId() == any::IdForType<U>()
              ? std::addressof(
-                   static_cast<any::Obj<T>*>(operand->obj_.get())->value)
+                   static_cast<any::Obj<U>*>(operand->obj_.get())->value)
              : nullptr;
 }