From 6ecac730193dd55ab76b2ea1b42471749e942d0d Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 13 Oct 2016 21:06:03 +0000 Subject: [PATCH] Implement http://wg21.link/p0302r1: Removing Allocator Support in std::function. These functions never worked, and as far as I know, no one ever called them. llvm-svn: 284164 --- libcxx/include/functional | 18 ++++-- .../func.wrap.func/derive_from.fail.cpp | 25 ++++++++ .../func.wrap.func/derive_from.pass.cpp | 3 + .../func.wrap.func.con/alloc.fail.cpp | 25 ++++++++ .../func.wrap.func.con/alloc.pass.cpp | 3 + .../func.wrap.func.con/alloc_F.fail.cpp | 29 +++++++++ .../func.wrap.func.con/alloc_F.pass.cpp | 1 + .../alloc_function.fail.cpp | 30 ++++++++++ .../alloc_function.pass.cpp | 1 + .../func.wrap.func.con/alloc_nullptr.fail.cpp | 27 +++++++++ .../func.wrap.func.con/alloc_nullptr.pass.cpp | 3 + .../alloc_rfunction.fail.cpp | 60 +++++++++++++++++++ .../alloc_rfunction.pass.cpp | 3 + libcxx/www/cxx1z_status.html | 4 +- 14 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp diff --git a/libcxx/include/functional b/libcxx/include/functional index 1461270d4b3b..4adb8c92aa31 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -393,15 +393,15 @@ public: template function(F); template - function(allocator_arg_t, const Alloc&) noexcept; + function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 template - function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; + function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 template - function(allocator_arg_t, const Alloc&, const function&); + function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 template - function(allocator_arg_t, const Alloc&, function&&); + function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 template - function(allocator_arg_t, const Alloc&, F); + function(allocator_arg_t, const Alloc&, F); // removed in C++17 function& operator=(const function&); function& operator=(function&&) noexcept; @@ -1617,6 +1617,7 @@ public: >::type> function(_Fp); +#if _LIBCPP_STD_VER <= 14 template _LIBCPP_INLINE_VISIBILITY function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} @@ -1629,6 +1630,7 @@ public: function(allocator_arg_t, const _Alloc&, function&&); template::value>::type> function(allocator_arg_t, const _Alloc& __a, _Fp __f); +#endif function& operator=(const function&); function& operator=(function&&) _NOEXCEPT; @@ -1689,6 +1691,7 @@ function<_Rp(_ArgTypes...)>::function(const function& __f) __f_ = __f.__f_->__clone(); } +#if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, @@ -1704,6 +1707,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, else __f_ = __f.__f_->__clone(); } +#endif template function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT @@ -1722,6 +1726,7 @@ function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT } } +#if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, @@ -1740,6 +1745,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, __f.__f_ = 0; } } +#endif template template @@ -1765,6 +1771,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f) } } +#if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f) @@ -1790,6 +1797,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _ } } } +#endif template function<_Rp(_ArgTypes...)>& diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp new file mode 100644 index 000000000000..e156fa966ac5 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// XFAIL: c++11, c++14 + +// + +#include +#include + +#include "test_macros.h" + +struct S : public std::function { using function::function; }; + +int main() { + S f1( [](){} ); + S f2(std::allocator_arg, std::allocator{}, f1); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp index bc8ab873b0aa..5bdf9e98e897 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 +// REQUIRES-ANY: c++11, c++14 // @@ -16,6 +17,8 @@ #include #include +#include "test_macros.h" + using Fn = std::function; struct S : public std::function { using function::function; }; diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp new file mode 100644 index 000000000000..f455f0311847 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// XFAIL: c++98, c++03, c++11, c++14 + +// class function + +// template function(allocator_arg_t, const A&); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + std::function f(std::allocator_arg, std::allocator()); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index f97e34d3f2cb..392dfc1993bc 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -8,10 +8,13 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function // template function(allocator_arg_t, const A&); +// +// This signature was removed in C++17 #include #include diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp new file mode 100644 index 000000000000..24f7fceb877b --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// XFAIL: c++98, c++03, c++11, c++14 + +// class function + +// template function(allocator_arg_t, const A&, F); +// +// This signature was removed in C++17 + +#include +#include + +#include "test_macros.h" + +void foo(int) {} + +int main() +{ + std::function f(std::allocator_arg, std::allocator(), foo); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index e662b6c24274..8d454723320c 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp new file mode 100644 index 000000000000..9967457ff821 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// XFAIL: c++98, c++03, c++11, c++14 + +// class function + +// template function(allocator_arg_t, const A&, const function&); +// +// This signature was removed in C++17 + + +#include +#include + +#include "test_macros.h" + +int main() +{ + typedef std::function F; + F f1; + F f2(std::allocator_arg, std::allocator(), f1); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index 371eb98de1a9..718aa49341d2 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp new file mode 100644 index 000000000000..cc4ecce75138 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// XFAIL: c++98, c++03, c++11, c++14 + +// class function + +// template function(allocator_arg_t, const A&, nullptr_t); +// +// This signature was removed in C++17 + +#include +#include + +#include "min_allocator.h" + +int main() +{ + std::function f(std::allocator_arg, std::allocator(), nullptr); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 2350f92f0f89..354ad955f207 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -8,10 +8,13 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function // template function(allocator_arg_t, const A&, nullptr_t); +// +// This signature was removed in C++17 #include #include diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp new file mode 100644 index 000000000000..cb9fb9afad2b --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// XFAIL: c++98, c++03, c++11, c++14 + +// class function + +// template function(allocator_arg_t, const A&, function&&); +// +// This signature was removed in C++17 + +#include +#include +#include + +#include "test_macros.h" + +class A +{ + int data_[10]; +public: + static int count; + + A() + { + ++count; + for (int i = 0; i < 10; ++i) + data_[i] = i; + } + + A(const A&) {++count;} + + ~A() {--count;} + + int operator()(int i) const + { + for (int j = 0; j < 10; ++j) + i += data_[j]; + return i; + } +}; + +int A::count = 0; + +int g(int) { return 0; } + +int main() +{ + { + std::function f = A(); + std::function f2(std::allocator_arg, std::allocator(), std::move(f)); + } +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index 403d646f4216..e328481b274d 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -8,12 +8,15 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 +// REQUIRES-ANY: c++11, c++14 // // class function // template function(allocator_arg_t, const A&, function&&); +// +// This signature was removed in C++17 #include #include diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index 95c9d88c7c44..c541ee5fa8f8 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -111,7 +111,7 @@ p0254r2LWGIntegrating std::string_view and std::stringOuluComplete4.0 p0258r2LWGhas_unique_object_representationsOulu p0295r0LWGAdopt Selected Library Fundamentals V2 Components for C++17OuluComplete4.0 - p0302r1LWGRemoving Allocator Support in std::functionOulu + p0302r1LWGRemoving Allocator Support in std::functionOuluComplete4.0 p0307r2LWGMaking Optional Greater Equal AgainOulu p0336r1LWGBetter Names for Parallel Execution Policies in C++17Oulu p0337r0LWGDelete operator= for polymorphic_allocatorOuluComplete3.9 @@ -317,7 +317,7 @@ -

Last Updated: 12-Jul-2016

+

Last Updated: 13-Oct-2016