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
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 will be removed in LLVM 16.
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 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.
+- ``unary_function`` and ``binary_function`` are now marked as ``[[deprecated]]`` in C++11 and later.
+ Deprecation warnings can be disabled by defining ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``, however
+ this disables all deprecation warnings, not only those for ``unary_function`` and ``binary_function``.
+ Also note that starting in LLVM 16, ``unary_function`` and ``binary_function`` will be removed entirely
+ (not only deprecated) in C++17 and above, as mandated by the Standard.
- The contents of ``<codecvt>``, ``wstring_convert`` and ``wbuffer_convert`` have been marked as deprecated.
To disable deprecation warnings you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this
- The contents of ``<codecvt>``, ``wstring_convert`` and ``wbuffer_convert`` have been marked as deprecated.
To disable deprecation warnings you have to define ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS``. Note that this
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+// Leave the deprecation notices in by default, but don't remove unary_function and
+// binary_function entirely just yet. That way, folks will have one release to act
+// on the deprecation warnings.
+# ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
+# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
+# endif
+
# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
#include <utility>
#include "test_macros.h"
#include <utility>
#include "test_macros.h"
+// This test is disabled in LLVM 15 because we enable the removed
+// unary_function and binary_function classes by default, which means
+// that we also don't produce deprecation warnings for using their members.
+
+// expected-no-diagnostics
+#if 0
void test_functional()
{
{
void test_functional()
{
{