aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-05-23 22:40:56 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-05-23 22:40:56 +0100
commit9a0af7e3fb425ae2c0e044d044feb81ef493ce2c (patch)
treea3d1f6bdc1b3b0ce8e8352e0048a022a8bee7691
parentaa992ce717568eb88b324d39429e52df04a42eb1 (diff)
downloadgcc-9a0af7e3fb425ae2c0e044d044feb81ef493ce2c.zip
gcc-9a0af7e3fb425ae2c0e044d044feb81ef493ce2c.tar.gz
gcc-9a0af7e3fb425ae2c0e044d044feb81ef493ce2c.tar.bz2
LWG 2921 remove packaged_task constructors taking allocators
* doc/xml/manual/evolution.xml: Document LWG DR 2921 change. * doc/xml/manual/intro.xml: Likewise. * include/std/future (__create_task_state): Add default arguments to make providing an allocator optional. (packaged_task::packaged_task(F&&)): Call __create_task_state directly instead of delegating to another constructor. (packaged_task::packaged_task(allocator_arg_t, const A&, ...)): Do not define allocator-extended constructors for C++17 and later. * testsuite/30_threads/packaged_task/cons/alloc.cc: Only run test for C++11 and C++14. * testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise. * testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise. * testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise. From-SVN: r271582
-rw-r--r--libstdc++-v3/ChangeLog16
-rw-r--r--libstdc++-v3/doc/xml/manual/evolution.xml5
-rw-r--r--libstdc++-v3/doc/xml/manual/intro.xml8
-rw-r--r--libstdc++-v3/include/std/future49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc3
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc2
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc2
8 files changed, 61 insertions, 26 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 17a0463..e230f24 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,19 @@
+2019-05-23 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/manual/evolution.xml: Document LWG DR 2921 change.
+ * doc/xml/manual/intro.xml: Likewise.
+ * include/std/future (__create_task_state): Add default arguments
+ to make providing an allocator optional.
+ (packaged_task::packaged_task(F&&)): Call __create_task_state directly
+ instead of delegating to another constructor.
+ (packaged_task::packaged_task(allocator_arg_t, const A&, ...)): Do not
+ define allocator-extended constructors for C++17 and later.
+ * testsuite/30_threads/packaged_task/cons/alloc.cc: Only run test for
+ C++11 and C++14.
+ * testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise.
+ * testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise.
+ * testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise.
+
2019-05-23 Hans-Peter Nilsson <hp@axis.com>
* testsuite/26_numerics/random/poisson_distribution/operators/values.cc:
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index 010907a..1bd7bb1 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -955,6 +955,11 @@ now defaults to zero.
</itemizedlist>
</para>
+<para>
+ The <classname>std::packaged_task</classname> constructors taking
+ an allocator argument are only defined for C++11 and C++14.
+</para>
+
</section>
</section>
diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml
index 35a2016..a216256 100644
--- a/libstdc++-v3/doc/xml/manual/intro.xml
+++ b/libstdc++-v3/doc/xml/manual/intro.xml
@@ -1221,6 +1221,14 @@ requirements of the license of GCC.
<listitem><para>Use rvalues for deleters.
</para></listitem></varlistentry>
+ <varlistentry xml:id="manual.bugs.dr2921"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2921">2921</link>:
+ <emphasis><code>packaged_task</code> and type-erased allocators
+ </emphasis>
+ </term>
+ <listitem><para>For C++17 mode, remove the constructors taking
+ an allocator argument.
+ </para></listitem></varlistentry>
+
<varlistentry xml:id="manual.bugs.dr2942"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2942">2942</link>:
<emphasis>LWG 2873's resolution missed
<code>weak_ptr::owner_before</code>
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 9671100..6c27669 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -1447,9 +1447,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} _M_impl;
};
- template<typename _Signature, typename _Fn, typename _Alloc>
+ template<typename _Signature, typename _Fn,
+ typename _Alloc = std::allocator<int>>
static shared_ptr<__future_base::_Task_state_base<_Signature>>
- __create_task_state(_Fn&& __fn, const _Alloc& __a)
+ __create_task_state(_Fn&& __fn, const _Alloc& __a = _Alloc())
{
typedef typename decay<_Fn>::type _Fn2;
typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State;
@@ -1481,28 +1482,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Construction and destruction
packaged_task() noexcept { }
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 2095. missing constructors needed for uses-allocator construction
- template<typename _Allocator>
- packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
- { }
-
template<typename _Fn, typename = __not_same<_Fn>>
explicit
packaged_task(_Fn&& __fn)
- : packaged_task(allocator_arg, std::allocator<int>(),
- std::forward<_Fn>(__fn))
+ : _M_state(
+ __create_task_state<_Res(_ArgTypes...)>(std::forward<_Fn>(__fn)))
{ }
+#if __cplusplus < 201703L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 2097. packaged_task constructors should be constrained
+ // 2097. packaged_task constructors should be constrained
// 2407. [this constructor should not be] explicit
+ // 2921. packaged_task and type-erased allocators
template<typename _Fn, typename _Alloc, typename = __not_same<_Fn>>
packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn)
: _M_state(__create_task_state<_Res(_ArgTypes...)>(
std::forward<_Fn>(__fn), __a))
{ }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2095. missing constructors needed for uses-allocator construction
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
+ { }
+
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator&,
+ const packaged_task&) = delete;
+
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator&,
+ packaged_task&& __other) noexcept
+ { this->swap(__other); }
+#endif
+
~packaged_task()
{
if (static_cast<bool>(_M_state) && !_M_state.unique())
@@ -1513,19 +1526,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
packaged_task(const packaged_task&) = delete;
packaged_task& operator=(const packaged_task&) = delete;
- template<typename _Allocator>
- packaged_task(allocator_arg_t, const _Allocator&,
- const packaged_task&) = delete;
-
// Move support
packaged_task(packaged_task&& __other) noexcept
{ this->swap(__other); }
- template<typename _Allocator>
- packaged_task(allocator_arg_t, const _Allocator&,
- packaged_task&& __other) noexcept
- { this->swap(__other); }
-
packaged_task& operator=(packaged_task&& __other) noexcept
{
packaged_task(std::move(__other)).swap(*this);
@@ -1577,10 +1581,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
packaged_task<_Res(_ArgTypes...)>& __y) noexcept
{ __x.swap(__y); }
+#if __cplusplus < 201703L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2976. Dangling uses_allocator specialization for packaged_task
template<typename _Res, typename _Alloc>
struct uses_allocator<packaged_task<_Res>, _Alloc>
: public true_type { };
-
+#endif
// Shared state created by std::async().
// Holds a deferred function and storage for its result.
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc
index b806c0b..815ae0d 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc
@@ -1,6 +1,5 @@
-// { dg-do run }
+// { dg-do run { target { c++11_only || c++14_only } } }
// { dg-options "-pthread" }
-// { dg-require-effective-target c++11 }
// { dg-require-effective-target pthread }
// { dg-require-gthreads "" }
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc
index 4159d00..06b60e5 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++11 } }
+// { dg-do compile { target { c++11_only || c++14_only } } }
// { dg-require-gthreads "" }
// Copyright (C) 2011-2019 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc
index 3ab1d1b..5ca0ba9 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++11 } }
+// { dg-do compile { target { c++11_only || c++14_only } } }
// { dg-require-gthreads "" }
// Copyright (C) 2011-2019 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc
index d251f89..5b1f244 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++11 } }
+// { dg-do compile { target { c++11_only || c++14_only } } }
// { dg-require-gthreads "" }
// Copyright (C) 2011-2019 Free Software Foundation, Inc.