EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch deprecates almost all C++03 extensions offered by <functional>. 
These extensions started as fallback implementations for compilers without 
variadic template support.
Since compiler support is no longer an issue I would like to remove these 
features. The end goal is to remove both `<__functional_03>` and 
`<__functional_base_03>` entirely. 

The features this patch deprecates are:

* `std::function`
* `std::mem_fn`
* `std::reference_wrapper::operator()`

Although `reference_wrapper` is C++11 only I chose to only deprecate the 
variadic call operator. The rest of the class will remain as an extension.

Killing these features allows us to kill the C++03 implementation of INVOKE and 
it's related traits, which have a poor QoI with a large maintenance burden. 


http://reviews.llvm.org/D19247

Files:
  include/__config
  include/__functional_03
  include/__functional_base
  include/functional

Index: include/functional
===================================================================
--- include/functional
+++ include/functional
@@ -1363,6 +1363,7 @@
 
 template<class _Rp, class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("std::mem_fn requires C++11 or newer")
 __mem_fn<_Rp _Tp::*>
 mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
 {
Index: include/__functional_base
===================================================================
--- include/__functional_base
+++ include/__functional_base
@@ -462,7 +462,8 @@
 };
 
 template <class _Tp>
-class _LIBCPP_TYPE_VIS_ONLY reference_wrapper
+class _LIBCPP_TYPE_VIS_ONLY
+  reference_wrapper
     : public __weak_result_type<_Tp>
 {
 public:
@@ -492,8 +493,8 @@
         return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
     }
 #else
-
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return<type>::type
     operator() () const {
         return __invoke(get());
@@ -501,6 +502,7 @@
 
     template <class _A0>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return0<type, _A0>::type
     operator() (_A0& __a0) const {
         return __invoke(get(), __a0);
@@ -508,6 +510,7 @@
 
     template <class _A0>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return0<type, _A0 const>::type
     operator() (_A0 const& __a0) const {
         return __invoke(get(), __a0);
@@ -515,6 +518,7 @@
 
     template <class _A0, class _A1>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return1<type, _A0, _A1>::type
     operator() (_A0& __a0, _A1& __a1) const {
         return __invoke(get(), __a0, __a1);
@@ -522,6 +526,7 @@
 
     template <class _A0, class _A1>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return1<type, _A0 const, _A1>::type
     operator() (_A0 const& __a0, _A1& __a1) const {
         return __invoke(get(), __a0, __a1);
@@ -529,6 +534,7 @@
 
     template <class _A0, class _A1>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return1<type, _A0, _A1 const>::type
     operator() (_A0& __a0, _A1 const& __a1) const {
         return __invoke(get(), __a0, __a1);
@@ -536,6 +542,7 @@
 
     template <class _A0, class _A1>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return1<type, _A0 const, _A1 const>::type
     operator() (_A0 const& __a0, _A1 const& __a1) const {
         return __invoke(get(), __a0, __a1);
@@ -543,6 +550,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0, _A1, _A2>::type
     operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -550,6 +558,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0 const, _A1, _A2>::type
     operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -557,6 +566,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0, _A1 const, _A2>::type
     operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -564,6 +574,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0, _A1, _A2 const>::type
     operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -571,6 +582,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
     operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -578,6 +590,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
     operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -585,6 +598,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
     operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
@@ -592,6 +606,7 @@
 
     template <class _A0, class _A1, class _A2>
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
     typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
     operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
         return __invoke(get(), __a0, __a1, __a2);
Index: include/__functional_03
===================================================================
--- include/__functional_03
+++ include/__functional_03
@@ -445,7 +445,9 @@
 }  // __function
 
 template<class _Rp>
-class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
+class _LIBCPP_TYPE_VIS_ONLY
+      _LIBCPP_DEPRECATED_CXX03_EXTENSION("std::function requires C++11 or newer")
+  function<_Rp()>
 {
     typedef __function::__base<_Rp()> __base;
     aligned_storage<3*sizeof(void*)>::type __buf_;
@@ -720,7 +722,9 @@
 #endif  // _LIBCPP_NO_RTTI
 
 template<class _Rp, class _A0>
-class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
+class _LIBCPP_TYPE_VIS_ONLY
+      _LIBCPP_DEPRECATED_CXX03_EXTENSION("std::function requires C++11 or newer")
+  function<_Rp(_A0)>
     : public unary_function<_A0, _Rp>
 {
     typedef __function::__base<_Rp(_A0)> __base;
@@ -996,7 +1000,9 @@
 #endif  // _LIBCPP_NO_RTTI
 
 template<class _Rp, class _A0, class _A1>
-class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
+class _LIBCPP_TYPE_VIS_ONLY
+      _LIBCPP_DEPRECATED_CXX03_EXTENSION("std::function requires C++11 or newer")
+  function<_Rp(_A0, _A1)>
     : public binary_function<_A0, _A1, _Rp>
 {
     typedef __function::__base<_Rp(_A0, _A1)> __base;
@@ -1272,7 +1278,9 @@
 #endif  // _LIBCPP_NO_RTTI
 
 template<class _Rp, class _A0, class _A1, class _A2>
-class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
+class _LIBCPP_TYPE_VIS_ONLY
+      _LIBCPP_DEPRECATED_CXX03_EXTENSION("std::function requires C++11 or newer")
+  function<_Rp(_A0, _A1, _A2)>
 {
     typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
     aligned_storage<3*sizeof(void*)>::type __buf_;
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -765,10 +765,28 @@
 #  endif
 #endif  // _LIBCPP_STD_VER
 
+#if __cplusplus < 201103L
+#define _LIBCPP_CXX03_LANG
+#else
+#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
+#endif
+#endif
+
 #if _LIBCPP_STD_VER > 11
 #define _LIBCPP_DEPRECATED [[deprecated]]
 #else
-#define _LIBCPP_DEPRECATED
+#define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
+#endif
+
+#ifdef _LIBCPP_CXX03_LANG
+#if __has_extension(attribute_deprecated_with_message)
+#define _LIBCPP_DEPRECATED_CXX03_EXTENSION(__msg) __attribute__((__deprecated__(__msg)))
+#else
+#define _LIBCPP_DEPRECATED_CXX03_EXTENSION(__msg) __attribute__((__deprecated__))
+#endif
+#else
+#define _LIBCPP_DEPRECATED_CXX03_EXTENSION(__msg)
 #endif
 
 #if _LIBCPP_STD_VER <= 11
@@ -863,13 +881,6 @@
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #endif
 
-#if __cplusplus < 201103L
-#define _LIBCPP_CXX03_LANG
-#else
-#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
-#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
-#endif
-#endif
 
 #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
       && __has_attribute(acquire_capability))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to