+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:
} _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;
// 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())
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);
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.