[libc++] [LWG2993] reference_wrapper<T> conversion from U&&
Implement the resolution of LWG2993. Replace a deleted constructor
with a constructor that SFINAEs away in appropriate circumstances.
Also, now that the constructor is templated, we must have an
explicit deduction guide to make CTAD work.
Some tests have been merged in from Agustín Bergé's D40259.
Differential Revision: https://reviews.llvm.org/D92725
GitOrigin-RevId: eec04092d67b94f47439a9065b6bd4cd60165be2
diff --git a/include/functional b/include/functional
index 67baa5b..f8565e7 100644
--- a/include/functional
+++ b/include/functional
@@ -42,8 +42,8 @@
typedef see below result_type; // Not always defined
// construct/copy/destroy
- reference_wrapper(T&) noexcept;
- reference_wrapper(T&&) = delete; // do not bind to temps
+ template<class U>
+ reference_wrapper(U&&);
reference_wrapper(const reference_wrapper<T>& x) noexcept;
// assignment
@@ -59,6 +59,9 @@
operator() (ArgTypes&&...) const;
};
+template <class T>
+ reference_wrapper(T&) -> reference_wrapper<T>;
+
template <class T> reference_wrapper<T> ref(T& t) noexcept;
template <class T> void ref(const T&& t) = delete;
template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;