Skip to content

Commit 8d802f7

Browse files
committed
[libc++] Keep unary_function and binary_function in C++17 for one more release
In LLVM 15, we added the deprecation markup for unary_function and binary_function for >= C++11, and we also removed it for >= C++17. While this is in accordance with the Standard, it's also a bit quick for our users, since there was no release in which the classes were marked as deprecated before their removal. We noticed widespread breakage due to this, and after months of trying to fix downstream failures, I am coming to the conclusion that users will be better served if we give them one release where unary_function is deprecated but still provided even in >= C++17. Differential Revision: https://reviews.llvm.org/D134473
1 parent 5d9fa4d commit 8d802f7

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ Deprecations and Removals
141141
or upgrade to C++11 or later. It is possible to re-enable ``std::function`` in C++03 by defining
142142
``_LIBCPP_ENABLE_CXX03_FUNCTION``. This option will be removed in LLVM 16.
143143

144-
- ``unary_function`` and ``binary_function`` are no longer available in C++17 and C++20.
145-
They can be re-enabled by defining ``_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION``.
146-
They are also marked as ``[[deprecated]]`` in C++11 and later. To disable deprecation warnings
147-
you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this disables
148-
all deprecation warnings.
144+
- ``unary_function`` and ``binary_function`` are now marked as ``[[deprecated]]`` in C++11 and later.
145+
Deprecation warnings can be disabled by defining ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``, however
146+
this disables all deprecation warnings, not only those for ``unary_function`` and ``binary_function``.
147+
Also note that starting in LLVM 16, ``unary_function`` and ``binary_function`` will be removed entirely
148+
(not only deprecated) in C++17 and above, as mandated by the Standard.
149149

150150
- The contents of ``<codecvt>``, ``wstring_convert`` and ``wbuffer_convert`` have been marked as deprecated.
151151
To disable deprecation warnings you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this

libcxx/include/__config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
11011101
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
11021102
# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
11031103

1104+
// Leave the deprecation notices in by default, but don't remove unary_function and
1105+
// binary_function entirely just yet. That way, folks will have one release to act
1106+
// on the deprecation warnings.
1107+
# ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1108+
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1109+
# endif
1110+
11041111
# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
11051112
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
11061113
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION

libcxx/test/libcxx/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#include <utility>
2020
#include "test_macros.h"
2121

22+
// This test is disabled in LLVM 15 because we enable the removed
23+
// unary_function and binary_function classes by default, which means
24+
// that we also don't produce deprecation warnings for using their members.
25+
26+
// expected-no-diagnostics
27+
#if 0
2228
void test_functional()
2329
{
2430
{
@@ -123,3 +129,4 @@ void test_map()
123129
(void)c;
124130
}
125131
}
132+
#endif

0 commit comments

Comments
 (0)