Skip to content

Commit 681cde7

Browse files
committed
[libc++] Complete the implementation of N4190
Fixes #37402 Reviewed By: ldionne Spies: EricWF, avogelsgesang, libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D124346
1 parent c475e31 commit 681cde7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+358
-540
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Implemented Papers
4343
- P0674R1 (Support arrays in ``make_shared`` and ``allocate_shared``)
4444
- P0980R1 (Making ``std::string`` constexpr)
4545
- P2216R3 (std::format improvements)
46-
47-
- Implemented P0174R2 (Deprecating Vestigial Library Parts in C++17)
46+
- P0174R2 (Deprecating Vestigial Library Parts in C++17)
47+
- N4190 (Removing auto_ptr, random_shuffle(), And Old <functional> Stuff)
4848

4949
- Marked the following papers as "Complete" (note that some of those might have
5050
been implemented in a previous release but not marked as such):
@@ -152,6 +152,12 @@ API Changes
152152
or upgrade to C++11 or later. It is possible to re-enable ``std::function`` in C++03 by defining
153153
``_LIBCPP_ENABLE_CXX03_FUNCTION``. This option it will be removed in LLVM 16.
154154

155+
- ``unary_function`` and ``binary_function`` are no longer available in C++17 and C++20.
156+
They can be re-enabled by defining ``_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION``.
157+
They are also marked as ``[[deprecated]]`` in C++11 and later. To disable deprecation warnings
158+
you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this disables
159+
all deprecation warnings.
160+
155161
ABI Changes
156162
-----------
157163

libcxx/docs/Status/Cxx17Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"`N3911 <https://wg21.link/n3911>`__","LWG","TransformationTrait Alias ``void_t``\ .","Urbana","|Complete|","3.6"
33
"`N4089 <https://wg21.link/n4089>`__","LWG","Safe conversions in ``unique_ptr<T[]>``\ .","Urbana","|In Progress|","3.9"
44
"`N4169 <https://wg21.link/n4169>`__","LWG","A proposal to add invoke function template","Urbana","|Complete|","3.7"
5-
"`N4190 <https://wg21.link/n4190>`__","LWG","Removing auto_ptr, random_shuffle(), And Old <functional> Stuff.","Urbana","|In Progress|",""
5+
"`N4190 <https://wg21.link/n4190>`__","LWG","Removing auto_ptr, random_shuffle(), And Old <functional> Stuff.","Urbana","|Complete|","15.0"
66
"`N4258 <https://wg21.link/n4258>`__","LWG","Cleaning-up noexcept in the Library.","Urbana","|In Progress|","3.7"
77
"`N4259 <https://wg21.link/n4259>`__","CWG","Wording for std::uncaught_exceptions","Urbana","|Complete|","3.7"
88
"`N4277 <https://wg21.link/n4277>`__","LWG","TriviallyCopyable ``reference_wrapper``\ .","Urbana","|Complete|","3.2"

libcxx/include/__config

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@
8383
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
8484
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
8585
# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
86-
// In C++20 and later, don't derive std::plus from std::binary_function,
87-
// nor std::negate from std::unary_function.
88-
# define _LIBCPP_ABI_NO_BINDER_BASES
8986
// Give reverse_iterator<T> one data member of type T, not two.
9087
// Also, in C++17 and later, don't derive iterator types from std::iterator.
9188
# define _LIBCPP_ABI_NO_ITERATOR_BASES
@@ -1116,6 +1113,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
11161113
# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
11171114
# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
11181115
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1116+
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
11191117
# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
11201118

11211119
# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)

libcxx/include/__functional/binary_function.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,37 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21+
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
22+
2123
template <class _Arg1, class _Arg2, class _Result>
22-
struct _LIBCPP_TEMPLATE_VIS binary_function
24+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function
2325
{
2426
typedef _Arg1 first_argument_type;
2527
typedef _Arg2 second_argument_type;
2628
typedef _Result result_type;
2729
};
2830

31+
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
32+
33+
template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base {
34+
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
35+
using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1;
36+
using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2;
37+
using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
38+
#endif
39+
};
40+
41+
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
42+
_LIBCPP_DIAGNOSTIC_PUSH
43+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
44+
template <class _Arg1, class _Arg2, class _Result>
45+
using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
46+
_LIBCPP_DIAGNOSTIC_POP
47+
#else
48+
template <class _Arg1, class _Arg2, class _Result>
49+
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
50+
#endif
51+
2952
_LIBCPP_END_NAMESPACE_STD
3053

3154
#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H

libcxx/include/__functional/binary_negate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323

2424
template <class _Predicate>
2525
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
26-
: public binary_function<typename _Predicate::first_argument_type,
27-
typename _Predicate::second_argument_type,
28-
bool>
26+
: public __binary_function<typename _Predicate::first_argument_type,
27+
typename _Predicate::second_argument_type,
28+
bool>
2929
{
3030
_Predicate __pred_;
3131
public:

libcxx/include/__functional/bind.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
264264
}
265265

266266
template<class _Fp, class ..._BoundArgs>
267-
class __bind
268-
#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
269-
: public __weak_result_type<typename decay<_Fp>::type>
270-
#endif
267+
class __bind : public __weak_result_type<typename decay<_Fp>::type>
271268
{
272269
protected:
273270
typedef typename decay<_Fp>::type _Fd;

libcxx/include/__functional/binder1st.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323

2424
template <class __Operation>
2525
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
26-
: public unary_function<typename __Operation::second_argument_type,
27-
typename __Operation::result_type>
26+
: public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type>
2827
{
2928
protected:
3029
__Operation op;

libcxx/include/__functional/binder2nd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323

2424
template <class __Operation>
2525
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
26-
: public unary_function<typename __Operation::first_argument_type,
27-
typename __Operation::result_type>
26+
: public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type>
2827
{
2928
protected:
3029
__Operation op;

libcxx/include/__functional/function.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct __maybe_derive_from_unary_function
8585

8686
template<class _Rp, class _A1>
8787
struct __maybe_derive_from_unary_function<_Rp(_A1)>
88-
: public unary_function<_A1, _Rp>
88+
: public __unary_function<_A1, _Rp>
8989
{
9090
};
9191

@@ -96,7 +96,7 @@ struct __maybe_derive_from_binary_function
9696

9797
template<class _Rp, class _A1, class _A2>
9898
struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
99-
: public binary_function<_A1, _A2, _Rp>
99+
: public __binary_function<_A1, _A2, _Rp>
100100
{
101101
};
102102

@@ -956,10 +956,8 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
956956

957957
template<class _Rp, class ..._ArgTypes>
958958
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
959-
#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
960959
: public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
961960
public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
962-
#endif
963961
{
964962
#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
965963
typedef __function::__value_func<_Rp(_ArgTypes...)> __func;

0 commit comments

Comments
 (0)