[libcxx-commits] [libcxx] 681cde7 - [libc++] Complete the implementation of N4190

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 22 01:13:28 PDT 2022


Author: Nikolas Klauser
Date: 2022-06-22T10:13:03+02:00
New Revision: 681cde7dd8b5613dbafc9ca54e0288477f946be3

URL: https://github.com/llvm/llvm-project/commit/681cde7dd8b5613dbafc9ca54e0288477f946be3
DIFF: https://github.com/llvm/llvm-project/commit/681cde7dd8b5613dbafc9ca54e0288477f946be3.diff

LOG: [libc++] Complete the implementation of N4190

Fixes #37402

Reviewed By: ldionne

Spies: EricWF, avogelsgesang, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D124346

Added: 
    libcxx/test/libcxx/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
    libcxx/test/libcxx/utilities/function.objects/refwrap/layout.unary.compile.pass.cpp
    libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.depr.verify.cpp
    libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.depr.verify.cpp
    libcxx/test/std/utilities/function.objects/refwrap/binder_typedefs.compile.pass.cpp

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/docs/Status/Cxx17Papers.csv
    libcxx/include/__config
    libcxx/include/__functional/binary_function.h
    libcxx/include/__functional/binary_negate.h
    libcxx/include/__functional/bind.h
    libcxx/include/__functional/binder1st.h
    libcxx/include/__functional/binder2nd.h
    libcxx/include/__functional/function.h
    libcxx/include/__functional/hash.h
    libcxx/include/__functional/mem_fn.h
    libcxx/include/__functional/mem_fun_ref.h
    libcxx/include/__functional/operations.h
    libcxx/include/__functional/pointer_to_binary_function.h
    libcxx/include/__functional/pointer_to_unary_function.h
    libcxx/include/__functional/reference_wrapper.h
    libcxx/include/__functional/unary_function.h
    libcxx/include/__functional/unary_negate.h
    libcxx/include/__functional/weak_result_type.h
    libcxx/include/__memory/auto_ptr.h
    libcxx/include/__memory/shared_ptr.h
    libcxx/include/__memory/unique_ptr.h
    libcxx/include/bitset
    libcxx/include/ext/__hash
    libcxx/include/map
    libcxx/include/memory
    libcxx/include/string
    libcxx/include/string_view
    libcxx/include/system_error
    libcxx/include/thread
    libcxx/include/typeindex
    libcxx/include/vector
    libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
    libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
    libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
    libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
    libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
    libcxx/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp
    libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
    libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp
    libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
    libcxx/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
    libcxx/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
    libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
    libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
    libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
    libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index 8f4f692977ae1..08397d9b64e42 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -43,8 +43,8 @@ Implemented Papers
 - P0674R1 (Support arrays in ``make_shared`` and ``allocate_shared``)
 - P0980R1 (Making ``std::string`` constexpr)
 - P2216R3 (std::format improvements)
-
-- Implemented P0174R2 (Deprecating Vestigial Library Parts in C++17)
+- P0174R2 (Deprecating Vestigial Library Parts in C++17)
+- N4190 (Removing auto_ptr, random_shuffle(), And Old <functional> Stuff)
 
 - Marked the following papers as "Complete" (note that some of those might have
   been implemented in a previous release but not marked as such):
@@ -152,6 +152,12 @@ API Changes
   or upgrade to C++11 or later. It is possible to re-enable ``std::function`` in C++03 by defining
   ``_LIBCPP_ENABLE_CXX03_FUNCTION``. This option it will be removed in LLVM 16.
 
+- ``unary_function`` and ``binary_function`` are no longer available in C++17 and C++20.
+  They can be re-enabled by defining ``_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION``.
+  They are also marked as ``[[deprecated]]`` in C++11 and later. To disable deprecation warnings
+  you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this disables
+  all deprecation warnings.
+
 ABI Changes
 -----------
 

diff  --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index 72291fdb6a223..2a996cea41263 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -2,7 +2,7 @@
 "`N3911 <https://wg21.link/n3911>`__","LWG","TransformationTrait Alias ``void_t``\ .","Urbana","|Complete|","3.6"
 "`N4089 <https://wg21.link/n4089>`__","LWG","Safe conversions in ``unique_ptr<T[]>``\ .","Urbana","|In Progress|","3.9"
 "`N4169 <https://wg21.link/n4169>`__","LWG","A proposal to add invoke function template","Urbana","|Complete|","3.7"
-"`N4190 <https://wg21.link/n4190>`__","LWG","Removing auto_ptr, random_shuffle(), And Old <functional> Stuff.","Urbana","|In Progress|",""
+"`N4190 <https://wg21.link/n4190>`__","LWG","Removing auto_ptr, random_shuffle(), And Old <functional> Stuff.","Urbana","|Complete|","15.0"
 "`N4258 <https://wg21.link/n4258>`__","LWG","Cleaning-up noexcept in the Library.","Urbana","|In Progress|","3.7"
 "`N4259 <https://wg21.link/n4259>`__","CWG","Wording for std::uncaught_exceptions","Urbana","|Complete|","3.7"
 "`N4277 <https://wg21.link/n4277>`__","LWG","TriviallyCopyable ``reference_wrapper``\ .","Urbana","|Complete|","3.2"

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index bb20b2c956ea9..6f02a3a975967 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -83,9 +83,6 @@
 #    define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
 #    define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
-// In C++20 and later, don't derive std::plus from std::binary_function,
-// nor std::negate from std::unary_function.
-#    define _LIBCPP_ABI_NO_BINDER_BASES
 // Give reverse_iterator<T> one data member of type T, not two.
 // Also, in C++17 and later, don't derive iterator types from std::iterator.
 #    define _LIBCPP_ABI_NO_ITERATOR_BASES
@@ -1116,6 +1113,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 #    define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
 #    define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 #    define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+#    define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
 #  endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
 #  if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)

diff  --git a/libcxx/include/__functional/binary_function.h b/libcxx/include/__functional/binary_function.h
index 51135ef51e12d..fdedb8b177dae 100644
--- a/libcxx/include/__functional/binary_function.h
+++ b/libcxx/include/__functional/binary_function.h
@@ -18,14 +18,37 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
 template <class _Arg1, class _Arg2, class _Result>
-struct _LIBCPP_TEMPLATE_VIS binary_function
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function
 {
     typedef _Arg1   first_argument_type;
     typedef _Arg2   second_argument_type;
     typedef _Result result_type;
 };
 
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
+template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+  using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1;
+  using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2;
+  using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
+_LIBCPP_DIAGNOSTIC_POP
+#else
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H

diff  --git a/libcxx/include/__functional/binary_negate.h b/libcxx/include/__functional/binary_negate.h
index 17c5c20668f38..c4977f4ebe126 100644
--- a/libcxx/include/__functional/binary_negate.h
+++ b/libcxx/include/__functional/binary_negate.h
@@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Predicate>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
-    : public binary_function<typename _Predicate::first_argument_type,
-                             typename _Predicate::second_argument_type,
-                             bool>
+    : public __binary_function<typename _Predicate::first_argument_type,
+                               typename _Predicate::second_argument_type,
+                               bool>
 {
     _Predicate __pred_;
 public:

diff  --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h
index c352406f85613..d1cbbb3d916e3 100644
--- a/libcxx/include/__functional/bind.h
+++ b/libcxx/include/__functional/bind.h
@@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
 }
 
 template<class _Fp, class ..._BoundArgs>
-class __bind
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public __weak_result_type<typename decay<_Fp>::type>
-#endif
+class __bind : public __weak_result_type<typename decay<_Fp>::type>
 {
 protected:
     typedef typename decay<_Fp>::type _Fd;

diff  --git a/libcxx/include/__functional/binder1st.h b/libcxx/include/__functional/binder1st.h
index 13b2459dff4d0..dea22c70e1f2d 100644
--- a/libcxx/include/__functional/binder1st.h
+++ b/libcxx/include/__functional/binder1st.h
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class __Operation>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
-    : public unary_function<typename __Operation::second_argument_type,
-                            typename __Operation::result_type>
+    : public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type>
 {
 protected:
     __Operation                               op;

diff  --git a/libcxx/include/__functional/binder2nd.h b/libcxx/include/__functional/binder2nd.h
index ff0f5f0816928..c98a146b6a663 100644
--- a/libcxx/include/__functional/binder2nd.h
+++ b/libcxx/include/__functional/binder2nd.h
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class __Operation>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
-    : public unary_function<typename __Operation::first_argument_type,
-                            typename __Operation::result_type>
+    : public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type>
 {
 protected:
     __Operation                                op;

diff  --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index ae066c658aa32..312443b67c3b6 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -85,7 +85,7 @@ struct __maybe_derive_from_unary_function
 
 template<class _Rp, class _A1>
 struct __maybe_derive_from_unary_function<_Rp(_A1)>
-    : public unary_function<_A1, _Rp>
+    : public __unary_function<_A1, _Rp>
 {
 };
 
@@ -96,7 +96,7 @@ struct __maybe_derive_from_binary_function
 
 template<class _Rp, class _A1, class _A2>
 struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
+    : public __binary_function<_A1, _A2, _Rp>
 {
 };
 
@@ -956,10 +956,8 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
 
 template<class _Rp, class ..._ArgTypes>
 class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
     : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
       public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
-#endif
 {
 #ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
     typedef __function::__value_func<_Rp(_ArgTypes...)> __func;

diff  --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index f1d5e27343a07..8a11931288cfa 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
 template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
 struct __scalar_hash;
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct __scalar_hash<_Tp, 0>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct __scalar_hash<_Tp, 1>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct __scalar_hash<_Tp, 2>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct __scalar_hash<_Tp, 3>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct __scalar_hash<_Tp, 4>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
     return _HashT()(__p);
 }
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template<class _Tp>
 struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp*, size_t>
-#endif
+    : public __unary_function<_Tp*, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp* __v) const _NOEXCEPT
     {
@@ -443,230 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<bool>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<bool, size_t>
-#endif
+    : public __unary_function<bool, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<char, size_t>
-#endif
+    : public __unary_function<char, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<signed char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<signed char, size_t>
-#endif
+    : public __unary_function<signed char, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<unsigned char, size_t>
-#endif
+    : public __unary_function<unsigned char, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
 #ifndef _LIBCPP_HAS_NO_CHAR8_T
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<char8_t, size_t>
-#endif
+    : public __unary_function<char8_t, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 #endif // !_LIBCPP_HAS_NO_CHAR8_T
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<char16_t, size_t>
-#endif
+    : public __unary_function<char16_t, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<char32_t, size_t>
-#endif
+    : public __unary_function<char32_t, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<wchar_t, size_t>
-#endif
+    : public __unary_function<wchar_t, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<short>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<short, size_t>
-#endif
+    : public __unary_function<short, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<unsigned short, size_t>
-#endif
+    : public __unary_function<unsigned short, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<int>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<int, size_t>
-#endif
+    : public __unary_function<int, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<unsigned int, size_t>
-#endif
+    : public __unary_function<unsigned int, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<long>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<long, size_t>
-#endif
+    : public __unary_function<long, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<unsigned long, size_t>
-#endif
+    : public __unary_function<unsigned long, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
 };
@@ -777,18 +617,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
     }
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp, bool = is_enum<_Tp>::value>
 struct _LIBCPP_TEMPLATE_VIS __enum_hash
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public unary_function<_Tp, size_t>
-#endif
+    : public __unary_function<_Tp, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(_Tp __v) const _NOEXCEPT
     {
@@ -810,18 +642,10 @@ struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
 
 #if _LIBCPP_STD_VER > 14
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-  : public unary_function<nullptr_t, size_t>
-#endif
+  : public __unary_function<nullptr_t, size_t>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(nullptr_t) const _NOEXCEPT {
         return 662607004ull;

diff  --git a/libcxx/include/__functional/mem_fn.h b/libcxx/include/__functional/mem_fn.h
index c0018038db1af..a5818b3f018c4 100644
--- a/libcxx/include/__functional/mem_fn.h
+++ b/libcxx/include/__functional/mem_fn.h
@@ -24,10 +24,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-class __mem_fn
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public __weak_result_type<_Tp>
-#endif
+class __mem_fn : public __weak_result_type<_Tp>
 {
 public:
     // types
@@ -42,6 +39,7 @@ class __mem_fn
     // invoke
     template <class... _ArgTypes>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+
     typename __invoke_return<type, _ArgTypes...>::type
     operator() (_ArgTypes&&... __args) const {
         return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);

diff  --git a/libcxx/include/__functional/mem_fun_ref.h b/libcxx/include/__functional/mem_fun_ref.h
index 81f48e66e7829..65aab0696c164 100644
--- a/libcxx/include/__functional/mem_fun_ref.h
+++ b/libcxx/include/__functional/mem_fun_ref.h
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template<class _Sp, class _Tp>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
-    : public unary_function<_Tp*, _Sp>
+    : public __unary_function<_Tp*, _Sp>
 {
     _Sp (_Tp::*__p_)();
 public:
@@ -36,7 +36,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
 
 template<class _Sp, class _Tp, class _Ap>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
-    : public binary_function<_Tp*, _Ap, _Sp>
+    : public __binary_function<_Tp*, _Ap, _Sp>
 {
     _Sp (_Tp::*__p_)(_Ap);
 public:
@@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap))
 
 template<class _Sp, class _Tp>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
-    : public unary_function<_Tp, _Sp>
+    : public __unary_function<_Tp, _Sp>
 {
     _Sp (_Tp::*__p_)();
 public:
@@ -72,7 +72,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
 
 template<class _Sp, class _Tp, class _Ap>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
-    : public binary_function<_Tp, _Ap, _Sp>
+    : public __binary_function<_Tp, _Ap, _Sp>
 {
     _Sp (_Tp::*__p_)(_Ap);
 public:
@@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
 
 template <class _Sp, class _Tp>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
-    : public unary_function<const _Tp*, _Sp>
+    : public __unary_function<const _Tp*, _Sp>
 {
     _Sp (_Tp::*__p_)() const;
 public:
@@ -108,7 +108,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
 
 template <class _Sp, class _Tp, class _Ap>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
-    : public binary_function<const _Tp*, _Ap, _Sp>
+    : public __binary_function<const _Tp*, _Ap, _Sp>
 {
     _Sp (_Tp::*__p_)(_Ap) const;
 public:
@@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const)
 
 template <class _Sp, class _Tp>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
-    : public unary_function<_Tp, _Sp>
+    : public __unary_function<_Tp, _Sp>
 {
     _Sp (_Tp::*__p_)() const;
 public:
@@ -144,7 +144,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
 
 template <class _Sp, class _Tp, class _Ap>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
-    : public binary_function<_Tp, _Ap, _Sp>
+    : public __binary_function<_Tp, _Ap, _Sp>
 {
     _Sp (_Tp::*__p_)(_Ap) const;
 public:

diff  --git a/libcxx/include/__functional/operations.h b/libcxx/include/__functional/operations.h
index 9df6d773fea7c..1c73c999db918 100644
--- a/libcxx/include/__functional/operations.h
+++ b/libcxx/include/__functional/operations.h
@@ -23,24 +23,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // Arithmetic operations
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS plus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x + __y;}
@@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS minus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x - __y;}
@@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS multiplies
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x * __y;}
@@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS divides
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x / __y;}
@@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS modulus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x % __y;}
@@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS negate
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : unary_function<_Tp, _Tp>
-#endif
+    : __unary_function<_Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x) const
         {return -__x;}
@@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void>
 
 // Bitwise operations
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS bit_and
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x & __y;}
@@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void>
 #endif
 
 #if _LIBCPP_STD_VER > 11
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp = void>
 struct _LIBCPP_TEMPLATE_VIS bit_not
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : unary_function<_Tp, _Tp>
-#endif
+    : __unary_function<_Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x) const
         {return ~__x;}
@@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS bit_or
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x | __y;}
@@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS bit_xor
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, _Tp>
-#endif
+    : __binary_function<_Tp, _Tp, _Tp>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef _Tp __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     _Tp operator()(const _Tp& __x, const _Tp& __y) const
         {return __x ^ __y;}
@@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
 
 // Comparison operations
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS equal_to
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x == __y;}
@@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS not_equal_to
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x != __y;}
@@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS less
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x < __y;}
@@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS less_equal
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x <= __y;}
@@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS greater_equal
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x >= __y;}
@@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS greater
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x > __y;}
@@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void>
 
 // Logical operations
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS logical_and
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x && __y;}
@@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS logical_not
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : unary_function<_Tp, bool>
-#endif
+    : __unary_function<_Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x) const
         {return !__x;}
@@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void>
 };
 #endif
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #if _LIBCPP_STD_VER > 11
 template <class _Tp = void>
 #else
 template <class _Tp>
 #endif
 struct _LIBCPP_TEMPLATE_VIS logical_or
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<_Tp, _Tp, bool>
-#endif
+    : __binary_function<_Tp, _Tp, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
     typedef bool __result_type;  // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
     bool operator()(const _Tp& __x, const _Tp& __y) const
         {return __x || __y;}

diff  --git a/libcxx/include/__functional/pointer_to_binary_function.h b/libcxx/include/__functional/pointer_to_binary_function.h
index 187e3098c4883..b2676c58f885a 100644
--- a/libcxx/include/__functional/pointer_to_binary_function.h
+++ b/libcxx/include/__functional/pointer_to_binary_function.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Arg1, class _Arg2, class _Result>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
-    : public binary_function<_Arg1, _Arg2, _Result>
+    : public __binary_function<_Arg1, _Arg2, _Result>
 {
     _Result (*__f_)(_Arg1, _Arg2);
 public:

diff  --git a/libcxx/include/__functional/pointer_to_unary_function.h b/libcxx/include/__functional/pointer_to_unary_function.h
index a0f98c1a55225..77d07adf20f02 100644
--- a/libcxx/include/__functional/pointer_to_unary_function.h
+++ b/libcxx/include/__functional/pointer_to_unary_function.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Arg, class _Result>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
-    : public unary_function<_Arg, _Result>
+    : public __unary_function<_Arg, _Result>
 {
     _Result (*__f_)(_Arg);
 public:

diff  --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h
index 497276a080f0f..8245e3a047340 100644
--- a/libcxx/include/__functional/reference_wrapper.h
+++ b/libcxx/include/__functional/reference_wrapper.h
@@ -23,10 +23,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS reference_wrapper
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : public __weak_result_type<_Tp>
-#endif
+class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp>
 {
 public:
     // types

diff  --git a/libcxx/include/__functional/unary_function.h b/libcxx/include/__functional/unary_function.h
index af2a0b967c5d4..f07cac175a99f 100644
--- a/libcxx/include/__functional/unary_function.h
+++ b/libcxx/include/__functional/unary_function.h
@@ -17,13 +17,35 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
 template <class _Arg, class _Result>
-struct _LIBCPP_TEMPLATE_VIS unary_function
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function
 {
     typedef _Arg    argument_type;
     typedef _Result result_type;
 };
 
+#endif // _LIBCPP_STD_VER <= 14
+
+template <class _Arg, class _Result> struct __unary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+  using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg;
+  using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+template <class _Arg, class _Result>
+using __unary_function = unary_function<_Arg, _Result>;
+_LIBCPP_DIAGNOSTIC_POP
+#else
+template <class _Arg, class _Result>
+using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H

diff  --git a/libcxx/include/__functional/unary_negate.h b/libcxx/include/__functional/unary_negate.h
index 7ff1f6e8791d8..7f081903fe441 100644
--- a/libcxx/include/__functional/unary_negate.h
+++ b/libcxx/include/__functional/unary_negate.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Predicate>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
-    : public unary_function<typename _Predicate::argument_type, bool>
+    : public __unary_function<typename _Predicate::argument_type, bool>
 {
     _Predicate __pred_;
 public:

diff  --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h
index 81e4bedd2d1db..96d8cf7146b11 100644
--- a/libcxx/include/__functional/weak_result_type.h
+++ b/libcxx/include/__functional/weak_result_type.h
@@ -40,8 +40,9 @@ struct __derives_from_unary_function
     struct __two {char __lx; char __lxx;};
     static __two __test(...);
     template <class _Ap, class _Rp>
-        static unary_function<_Ap, _Rp>
-        __test(const volatile unary_function<_Ap, _Rp>*);
+        static __unary_function<_Ap, _Rp>
+        __test(const volatile __unary_function<_Ap, _Rp>*);
+
 public:
     static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
     typedef decltype(__test((_Tp*)0)) type;
@@ -54,8 +55,9 @@ struct __derives_from_binary_function
     struct __two {char __lx; char __lxx;};
     static __two __test(...);
     template <class _A1, class _A2, class _Rp>
-        static binary_function<_A1, _A2, _Rp>
-        __test(const volatile binary_function<_A1, _A2, _Rp>*);
+        static __binary_function<_A1, _A2, _Rp>
+        __test(const volatile __binary_function<_A1, _A2, _Rp>*);
+
 public:
     static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
     typedef decltype(__test((_Tp*)0)) type;
@@ -88,7 +90,9 @@ struct __weak_result_type_imp // bool is true
     : public __maybe_derive_from_unary_function<_Tp>,
       public __maybe_derive_from_binary_function<_Tp>
 {
-    typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type;
+#endif
 };
 
 template <class _Tp>
@@ -109,62 +113,68 @@ struct __weak_result_type
 template <class _Rp>
 struct __weak_result_type<_Rp ()>
 {
-    typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp>
 struct __weak_result_type<_Rp (&)()>
 {
-    typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp>
 struct __weak_result_type<_Rp (*)()>
 {
-    typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 // 1 argument case
 
 template <class _Rp, class _A1>
 struct __weak_result_type<_Rp (_A1)>
-    : public unary_function<_A1, _Rp>
+    : public __unary_function<_A1, _Rp>
 {
 };
 
 template <class _Rp, class _A1>
 struct __weak_result_type<_Rp (&)(_A1)>
-    : public unary_function<_A1, _Rp>
+    : public __unary_function<_A1, _Rp>
 {
 };
 
 template <class _Rp, class _A1>
 struct __weak_result_type<_Rp (*)(_A1)>
-    : public unary_function<_A1, _Rp>
+    : public __unary_function<_A1, _Rp>
 {
 };
 
 template <class _Rp, class _Cp>
 struct __weak_result_type<_Rp (_Cp::*)()>
-    : public unary_function<_Cp*, _Rp>
+    : public __unary_function<_Cp*, _Rp>
 {
 };
 
 template <class _Rp, class _Cp>
 struct __weak_result_type<_Rp (_Cp::*)() const>
-    : public unary_function<const _Cp*, _Rp>
+    : public __unary_function<const _Cp*, _Rp>
 {
 };
 
 template <class _Rp, class _Cp>
 struct __weak_result_type<_Rp (_Cp::*)() volatile>
-    : public unary_function<volatile _Cp*, _Rp>
+    : public __unary_function<volatile _Cp*, _Rp>
 {
 };
 
 template <class _Rp, class _Cp>
 struct __weak_result_type<_Rp (_Cp::*)() const volatile>
-    : public unary_function<const volatile _Cp*, _Rp>
+    : public __unary_function<const volatile _Cp*, _Rp>
 {
 };
 
@@ -172,43 +182,43 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile>
 
 template <class _Rp, class _A1, class _A2>
 struct __weak_result_type<_Rp (_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
+    : public __binary_function<_A1, _A2, _Rp>
 {
 };
 
 template <class _Rp, class _A1, class _A2>
 struct __weak_result_type<_Rp (*)(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
+    : public __binary_function<_A1, _A2, _Rp>
 {
 };
 
 template <class _Rp, class _A1, class _A2>
 struct __weak_result_type<_Rp (&)(_A1, _A2)>
-    : public binary_function<_A1, _A2, _Rp>
+    : public __binary_function<_A1, _A2, _Rp>
 {
 };
 
 template <class _Rp, class _Cp, class _A1>
 struct __weak_result_type<_Rp (_Cp::*)(_A1)>
-    : public binary_function<_Cp*, _A1, _Rp>
+    : public __binary_function<_Cp*, _A1, _Rp>
 {
 };
 
 template <class _Rp, class _Cp, class _A1>
 struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
-    : public binary_function<const _Cp*, _A1, _Rp>
+    : public __binary_function<const _Cp*, _A1, _Rp>
 {
 };
 
 template <class _Rp, class _Cp, class _A1>
 struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
-    : public binary_function<volatile _Cp*, _A1, _Rp>
+    : public __binary_function<volatile _Cp*, _A1, _Rp>
 {
 };
 
 template <class _Rp, class _Cp, class _A1>
 struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
-    : public binary_function<const volatile _Cp*, _A1, _Rp>
+    : public __binary_function<const volatile _Cp*, _A1, _Rp>
 {
 };
 
@@ -217,43 +227,57 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
 struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
 struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
 struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
 {
-    typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+    using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
 };
 
 template <class _Tp, class ..._Args>

diff  --git a/libcxx/include/__memory/auto_ptr.h b/libcxx/include/__memory/auto_ptr.h
index 163a46b631f0c..c007b4d21a5d2 100644
--- a/libcxx/include/__memory/auto_ptr.h
+++ b/libcxx/include/__memory/auto_ptr.h
@@ -16,6 +16,8 @@
 #  pragma GCC system_header
 #endif
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
@@ -77,4 +79,6 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void>
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+
 #endif // _LIBCPP___MEMORY_AUTO_PTR_H

diff  --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 25aa9bada5344..41a7c7fa7575f 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -20,6 +20,7 @@
 #include <__memory/allocation_guard.h>
 #include <__memory/allocator.h>
 #include <__memory/allocator_traits.h>
+#include <__memory/auto_ptr.h>
 #include <__memory/compressed_pair.h>
 #include <__memory/construct_at.h>
 #include <__memory/pointer_traits.h>
@@ -38,9 +39,6 @@
 #  include <atomic>
 #endif
 
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-#   include <__memory/auto_ptr.h>
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -1657,19 +1655,10 @@ template <class _Tp> struct owner_less;
 #endif
 
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
-#endif
+    : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> second_argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
         {return __x.owner_before(__y);}
@@ -1681,19 +1670,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
         {return __x.owner_before(__y);}
 };
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
-    : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
-#endif
+    : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
 {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> first_argument_type;
-    _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> second_argument_type;
-#endif
     _LIBCPP_INLINE_VISIBILITY
     bool operator()(  weak_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const _NOEXCEPT
         {return __x.owner_before(__y);}

diff  --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index 4816ee731cac9..1de64de30b232 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -14,16 +14,13 @@
 #include <__functional/hash.h>
 #include <__functional/operations.h>
 #include <__memory/allocator_traits.h> // __pointer
+#include <__memory/auto_ptr.h>
 #include <__memory/compressed_pair.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <cstddef>
 #include <type_traits>
 
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-#   include <__memory/auto_ptr.h>
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif

diff  --git a/libcxx/include/bitset b/libcxx/include/bitset
index 999363d209645..0f997cef83163 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -1090,7 +1090,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
 
 template <size_t _Size>
 struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
-    : public unary_function<bitset<_Size>, size_t>
+    : public __unary_function<bitset<_Size>, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT

diff  --git a/libcxx/include/ext/__hash b/libcxx/include/ext/__hash
index 989536104b010..0e6c2cc05b529 100644
--- a/libcxx/include/ext/__hash
+++ b/libcxx/include/ext/__hash
@@ -21,7 +21,7 @@ namespace __gnu_cxx {
 template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
- : public std::unary_function<const char*, size_t>
+ : public std::__unary_function<const char*, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const char *__c) const _NOEXCEPT
@@ -31,7 +31,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
- : public std::unary_function<char*, size_t>
+ : public std::__unary_function<char*, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char *__c) const _NOEXCEPT
@@ -41,7 +41,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
- : public std::unary_function<char, size_t>
+ : public std::__unary_function<char, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(char __c) const _NOEXCEPT
@@ -51,7 +51,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
- : public std::unary_function<signed char, size_t>
+ : public std::__unary_function<signed char, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(signed char __c) const _NOEXCEPT
@@ -61,7 +61,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
- : public std::unary_function<unsigned char, size_t>
+ : public std::__unary_function<unsigned char, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned char __c) const _NOEXCEPT
@@ -71,7 +71,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
- : public std::unary_function<short, size_t>
+ : public std::__unary_function<short, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(short __c) const _NOEXCEPT
@@ -81,7 +81,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
- : public std::unary_function<unsigned short, size_t>
+ : public std::__unary_function<unsigned short, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned short __c) const _NOEXCEPT
@@ -91,7 +91,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
-    : public std::unary_function<int, size_t>
+    : public std::__unary_function<int, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(int __c) const _NOEXCEPT
@@ -101,7 +101,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
-    : public std::unary_function<unsigned int, size_t>
+    : public std::__unary_function<unsigned int, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned int __c) const _NOEXCEPT
@@ -111,7 +111,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
-    : public std::unary_function<long, size_t>
+    : public std::__unary_function<long, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(long __c) const _NOEXCEPT
@@ -121,7 +121,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
 };
 
 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
-    : public std::unary_function<unsigned long, size_t>
+    : public std::__unary_function<unsigned long, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(unsigned long __c) const _NOEXCEPT

diff  --git a/libcxx/include/map b/libcxx/include/map
index 03ae15417c777..b253d0ffc8487 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -979,24 +979,15 @@ public:
     static_assert((is_same<typename allocator_type::value_type, value_type>::value),
                   "Allocator::value_type must be same type as value_type");
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
     class _LIBCPP_TEMPLATE_VIS value_compare
-#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-        : public binary_function<value_type, value_type, bool>
-#endif
+        : public __binary_function<value_type, value_type, bool>
     {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
         friend class map;
     protected:
         key_compare comp;
 
         _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
     public:
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
-#endif
         _LIBCPP_INLINE_VISIBILITY
         bool operator()(const value_type& __x, const value_type& __y) const
             {return comp(__x.first, __y.first);}
@@ -1764,13 +1755,9 @@ public:
     static_assert((is_same<typename allocator_type::value_type, value_type>::value),
                   "Allocator::value_type must be same type as value_type");
 
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
     class _LIBCPP_TEMPLATE_VIS value_compare
-#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-        : public binary_function<value_type, value_type, bool>
-#endif
+        : public __binary_function<value_type, value_type, bool>
     {
-_LIBCPP_SUPPRESS_DEPRECATED_POP
         friend class multimap;
     protected:
         key_compare comp;
@@ -1778,11 +1765,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
         _LIBCPP_INLINE_VISIBILITY
         value_compare(key_compare c) : comp(c) {}
     public:
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
-        _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
-#endif
         _LIBCPP_INLINE_VISIBILITY
         bool operator()(const value_type& __x, const value_type& __y) const
             {return comp(__x.first, __y.first);}

diff  --git a/libcxx/include/memory b/libcxx/include/memory
index 199ebe8c33eb9..aafe4bf4ba00a 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -847,6 +847,7 @@ template<size_t N, class T>
 #include <__memory/allocator_arg_t.h>
 #include <__memory/allocator_traits.h>
 #include <__memory/assume_aligned.h>
+#include <__memory/auto_ptr.h>
 #include <__memory/compressed_pair.h>
 #include <__memory/concepts.h>
 #include <__memory/construct_at.h>
@@ -873,10 +874,6 @@ template<size_t N, class T>
 // standard-mandated includes
 #include <compare>
 
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-#   include <__memory/auto_ptr.h>
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif

diff  --git a/libcxx/include/string b/libcxx/include/string
index ac0721f292b1f..ab8d2ac446d1c 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -4539,15 +4539,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type
 template <class _CharT, class _Allocator>
 struct _LIBCPP_TEMPLATE_VIS
     hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
-    : public unary_function<
-          basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
+    : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
 {
     size_t
     operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT
     { return __do_string_hash(__val.data(), __val.data() + __val.size()); }
 };
 
-
 template<class _CharT, class _Traits, class _Allocator>
 basic_ostream<_CharT, _Traits>&
 operator<<(basic_ostream<_CharT, _Traits>& __os,

diff  --git a/libcxx/include/string_view b/libcxx/include/string_view
index 1f64802e817f3..8088f66bcdc57 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -914,7 +914,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
 // [string.view.hash]
 template<class _CharT>
 struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
-    : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
+    : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
@@ -922,7 +922,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> >
     }
 };
 
-
 #if _LIBCPP_STD_VER > 11
 inline namespace literals
 {

diff  --git a/libcxx/include/system_error b/libcxx/include/system_error
index d9fe8b211bd73..2db901847d830 100644
--- a/libcxx/include/system_error
+++ b/libcxx/include/system_error
@@ -438,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
 
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<error_code>
-    : public unary_function<error_code, size_t>
+    : public __unary_function<error_code, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const error_code& __ec) const _NOEXCEPT
@@ -449,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code>
 
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<error_condition>
-    : public unary_function<error_condition, size_t>
+    : public __unary_function<error_condition, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const error_condition& __ec) const _NOEXCEPT

diff  --git a/libcxx/include/thread b/libcxx/include/thread
index b4f782455e526..06b4824d4c6f8 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -201,7 +201,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
 
 template<>
 struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
-    : public unary_function<__thread_id, size_t>
+    : public __unary_function<__thread_id, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(__thread_id __v) const _NOEXCEPT

diff  --git a/libcxx/include/typeindex b/libcxx/include/typeindex
index 416e48b8d398f..fb61cfc817696 100644
--- a/libcxx/include/typeindex
+++ b/libcxx/include/typeindex
@@ -95,7 +95,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
 
 template <>
 struct _LIBCPP_TEMPLATE_VIS hash<type_index>
-    : public unary_function<type_index, size_t>
+    : public __unary_function<type_index, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(type_index __index) const _NOEXCEPT

diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 0abf521e4337b..1cb4cbf107948 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -3139,7 +3139,7 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
 
 template <class _Allocator>
 struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
-    : public unary_function<vector<bool, _Allocator>, size_t>
+    : public __unary_function<vector<bool, _Allocator>, size_t>
 {
     _LIBCPP_INLINE_VISIBILITY
     size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT

diff  --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
index 0fd08cebd8374..f14359f54a4fb 100644
--- a/libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
@@ -6,7 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: c++03 || c++11 || c++14 || c++17
+// REQUIRES: c++03 || c++11 || c++14
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 // <functional>
 

diff  --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
new file mode 100644
index 0000000000000..023ed8ddbfa37
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: msvc
+
+// ensure that binary_function always has the same ABI
+
+#include <functional>
+
+struct S1 : std::less<int>, std::greater<int> {};
+
+static_assert(sizeof(S1) == 2, "");
+
+struct S2 : std::less<int> { char c; };
+
+static_assert(sizeof(S2) == 1, "");

diff  --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.unary.compile.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.unary.compile.pass.cpp
new file mode 100644
index 0000000000000..58b8dc5dc5377
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/function.objects/refwrap/layout.unary.compile.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11
+// UNSUPPORTED: msvc
+
+// ensure that unary_function always has the same ABI
+
+#include <functional>
+
+struct S1 : std::negate<int>, std::bit_not<int> {};
+
+static_assert(sizeof(S1) == 2, "");
+
+struct S2 : std::negate<int> { char c; };
+
+static_assert(sizeof(S2) == 1, "");

diff  --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
index 33b3336f63743..4d7ab16ec366f 100644
--- a/libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
@@ -6,7 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: c++03 || c++11 || c++14 || c++17
+// REQUIRES: c++03 || c++11 || c++14
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 // <functional>
 

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
index cda5ba8acfe75..04380c9764e7d 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
@@ -10,7 +10,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -30,8 +29,10 @@ int main(int, char**)
     {
     typedef std::vector<bool> T;
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<H::argument_type, T>::value), "" );
     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
 
     bool ba[] = {true, false, true, true, false};
@@ -43,8 +44,10 @@ int main(int, char**)
     {
     typedef std::vector<bool, min_allocator<bool>> T;
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<H::argument_type, T>::value), "" );
     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
     bool ba[] = {true, false, true, true, false};
     T vb(std::begin(ba), std::end(ba));

diff  --git a/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.depr.verify.cpp b/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.depr.verify.cpp
new file mode 100644
index 0000000000000..e5cdd91731f04
--- /dev/null
+++ b/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.depr.verify.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+// REQUIRES: c++11 || c++14
+// binary_function was removed in C++17
+
+// check that binary_function is marked deprecated
+
+#include <functional>
+
+std::binary_function<int, int, int> b; // expected-warning {{'binary_function<int, int, int>' is deprecated}}

diff  --git a/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp b/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
index 80a89c9602b86..3185de2b011e6 100644
--- a/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
+++ b/libcxx/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
@@ -10,6 +10,8 @@
 // REQUIRES: c++03 || c++11 || c++14
 // binary_function was removed in C++17
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 // template <class Arg1, class Arg2, class Result>
 // struct binary_function
 // {

diff  --git a/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.depr.verify.cpp b/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.depr.verify.cpp
new file mode 100644
index 0000000000000..b27f200fa931e
--- /dev/null
+++ b/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.depr.verify.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+// REQUIRES: c++11 || c++14
+// unary_function was removed in C++17
+
+// check that unary_function is marked deprecated
+
+#include <functional>
+
+std::unary_function<int, int> u; // expected-warning {{'unary_function<int, int>' is deprecated}}

diff  --git a/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp b/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
index 547a4c3aa4428..bcc4a04ea48bf 100644
--- a/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
+++ b/libcxx/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
@@ -10,6 +10,8 @@
 // REQUIRES: c++03 || c++11 || c++14
 // unary_function was removed in C++17
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 // template <class Arg, class Result>
 // struct unary_function
 // {

diff  --git a/libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
index f8c09775f2329..2e07d090d23b4 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
@@ -10,7 +10,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -26,8 +25,10 @@ test(int i)
 {
     typedef std::error_code T;
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<H::argument_type, T>::value), "" );
     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
     H h;
     T ec(i, std::system_category());

diff  --git a/libcxx/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp
index b9b0057b98fb6..bf016e1e55837 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp
@@ -10,7 +10,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -26,8 +25,10 @@ test(int i)
 {
     typedef std::error_condition T;
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<H::argument_type, T>::value), "" );
     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
     H h;
     T ec(i, std::system_category());

diff  --git a/libcxx/test/std/strings/basic.string.hash/strings.pass.cpp b/libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
index 6f902499d162b..576184a4a45aa 100644
--- a/libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
+++ b/libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
@@ -10,7 +10,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -28,8 +27,10 @@ void
 test()
 {
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<typename H::argument_type, T>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
 
     H h;

diff  --git a/libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp b/libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp
index 56e39a4696702..0770926c2fa72 100644
--- a/libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.hash/string_view.pass.cpp
@@ -12,7 +12,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -33,8 +32,10 @@ void
 test()
 {
     typedef std::hash<SV> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<typename H::argument_type, SV>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
 
     typedef typename SV::value_type char_type;
     typedef std::basic_string<char_type> String;

diff  --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
index 7ce5593c8af21..60c16cdb46012 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
@@ -12,7 +12,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -29,8 +28,10 @@ int main(int, char**)
     std::thread::id id1;
     std::thread::id id2 = std::this_thread::get_id();
     typedef std::hash<std::thread::id> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(id2));
     H h;
     assert(h(id1) != h(id2));

diff  --git a/libcxx/test/std/utilities/function.objects/func.require/binary_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
index 7422e7a76d331..9302bf6c2ddd2 100644
--- a/libcxx/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
@@ -10,6 +10,8 @@
 // REQUIRES: c++03 || c++11 || c++14
 // binary_function was removed in C++17
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 // binary_function
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/function.objects/func.require/unary_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
index 385a2f39dede3..224e9fe6eaa5e 100644
--- a/libcxx/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
@@ -10,6 +10,8 @@
 // REQUIRES: c++03 || c++11 || c++14
 // unary_function was removed in C++17
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 // unary_function
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/function.objects/refwrap/binder_typedefs.compile.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/binder_typedefs.compile.pass.cpp
new file mode 100644
index 0000000000000..23fd0a1361616
--- /dev/null
+++ b/libcxx/test/std/utilities/function.objects/refwrap/binder_typedefs.compile.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: c++03 || c++11 || c++14 || c++17
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
+// <functional>
+
+// reference_wrapper
+
+// check that binder typedefs exit
+
+#include <functional>
+#include <type_traits>
+
+struct UnaryFunction
+{
+    typedef long argument_type;
+    typedef char result_type;
+};
+
+struct BinaryFunction
+{
+    typedef int first_argument_type;
+    typedef char second_argument_type;
+    typedef long result_type;
+};
+
+static_assert(std::is_same<std::reference_wrapper<int(UnaryFunction::*)()>::result_type, int>::value, "");
+static_assert(std::is_same<std::reference_wrapper<int(UnaryFunction::*)()>::argument_type, UnaryFunction*>::value, "");
+
+static_assert(std::is_same<std::reference_wrapper<int(BinaryFunction::*)(char)>::result_type, int>::value, "");
+static_assert(std::is_same<std::reference_wrapper<int(BinaryFunction::*)(char)>::first_argument_type, BinaryFunction*>::value, "");
+static_assert(std::is_same<std::reference_wrapper<int(BinaryFunction::*)(char)>::second_argument_type, char>::value, "");
+
+static_assert(std::is_same<std::reference_wrapper<void(*)()>::result_type, void>::value, "");

diff  --git a/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
index ec62a06be5c3b..512d4e62ba8b8 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
@@ -14,6 +14,8 @@
 
 // REQUIRES: c++03 || c++11 || c++14 || c++17
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 #include <functional>
 #include <type_traits>
 

diff  --git a/libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
index dfac9d94af7c7..2e407ad9c342a 100644
--- a/libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
+++ b/libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
@@ -10,7 +10,6 @@
 
 // template <class T>
 // struct hash
-//     : public unary_function<T, size_t>
 // {
 //     size_t operator()(T val) const;
 // };
@@ -27,8 +26,10 @@ test()
 {
     typedef std::bitset<N> T;
     typedef std::hash<T> H;
+#if TEST_STD_VER <= 14
     static_assert((std::is_same<typename H::argument_type, T>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
     ASSERT_NOEXCEPT(H()(T()));
 
     H h;

diff  --git a/libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp b/libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
index aae9472856607..621aa71d5cfa6 100644
--- a/libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
+++ b/libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
@@ -12,7 +12,6 @@
 
 // template <>
 // struct hash<type_index>
-//     : public unary_function<type_index, size_t>
 // {
 //     size_t operator()(type_index index) const;
 // };
@@ -27,9 +26,11 @@
 
 int main(int, char**)
 {
+#if TEST_STD_VER <= 14
     typedef std::hash<std::type_index> H;
     static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
 
     std::type_index t1 = typeid(int);
     assert(std::hash<std::type_index>()(t1) == t1.hash_code());

diff  --git a/libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
index 70a2e80b656c6..a36175875b695 100644
--- a/libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
+++ b/libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
@@ -9,7 +9,6 @@
 // <typeindex>
 
 // struct hash<type_index>
-//     : public unary_function<type_index, size_t>
 // {
 //     size_t operator()(type_index index) const;
 // };
@@ -27,9 +26,11 @@
 int main(int, char**)
 {
   {
+#if TEST_STD_VER <= 14
     typedef std::hash<std::type_index> H;
     static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+#endif
   }
 #if TEST_STD_VER >= 11
   {


        


More information about the libcxx-commits mailing list