Skip to content

Commit c475e31

Browse files
committed
[libc++] Remove std::function in C++03
`std::function` has been deprecated for a few releases now. Remove it with an option to opt-back-in with a note that this option will be removed in LLVM 16. Reviewed By: ldionne, #libc Spies: #libc_vendors, EricWF, jloser, libcxx-commits Differential Revision: https://reviews.llvm.org/D127908
1 parent b09426f commit c475e31

File tree

28 files changed

+33
-27
lines changed

28 files changed

+33
-27
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ API Changes
148148
will be removed in LLVM 17. You can disable the deprecation warnings by defining
149149
``_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_SEARCHERS``.
150150

151+
- ``std::function`` has been removed in C++03. If you are using it, please remove usages
152+
or upgrade to C++11 or later. It is possible to re-enable ``std::function`` in C++03 by defining
153+
``_LIBCPP_ENABLE_CXX03_FUNCTION``. This option it will be removed in LLVM 16.
154+
151155
ABI Changes
152156
-----------
153157

libcxx/include/__functional/function.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ void
12421242
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
12431243
{return __x.swap(__y);}
12441244

1245-
#else // _LIBCPP_CXX03_LANG
1245+
#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)
12461246

12471247
namespace __function {
12481248

@@ -2808,7 +2808,7 @@ void
28082808
swap(function<_Fp>& __x, function<_Fp>& __y)
28092809
{return __x.swap(__y);}
28102810

2811-
#endif
2811+
#endif // _LIBCPP_CXX03_LANG
28122812

28132813
_LIBCPP_END_NAMESPACE_STD
28142814

libcxx/test/libcxx/utilities/function.objects/func.wrap/depr_in_cxx03.verify.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
// REQUIRES: c++03
1515

16+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX03_FUNCTION
17+
1618
#include <functional>
1719
#include "test_macros.h"
1820

libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// function& operator=(function &&);
1414

1515
// This test runs in C++03, but we have deprecated using std::function in C++03.
16-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
16+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1717

1818
#include <functional>
1919
#include <cassert>

libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// function& operator=(nullptr_t);
1414

1515
// This test runs in C++03, but we have deprecated using std::function in C++03.
16-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
16+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1717

1818
#include <functional>
1919
#include <cassert>

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/addressof.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// class function<R(ArgTypes...)>
1212

1313
// This test runs in C++03, but we have deprecated using std::function in C++03.
14-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
14+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1515

1616
// Make sure we can use std::function with a type that has a hostile overload
1717
// of operator&().

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
1515

1616
// This test runs in C++03, but we have deprecated using std::function in C++03.
17-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
17+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1818

1919
#include <functional>
2020
#include <cstdlib>

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// explicit operator bool() const
1414

1515
// This test runs in C++03, but we have deprecated using std::function in C++03.
16-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
16+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1717

1818
#include <functional>
1919
#include <cassert>

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// function(F);
1414

1515
// This test runs in C++03, but we have deprecated using std::function in C++03.
16-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
16+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
1717

1818
#include <functional>
1919
#include <cassert>

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// operator=(F f);
1717

1818
// This test runs in C++03, but we have deprecated using std::function in C++03.
19-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
19+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
2020

2121
#include <functional>
2222
#include <cassert>

0 commit comments

Comments
 (0)