diff options
| author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-03-18 16:31:38 +0000 |
|---|---|---|
| committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-03-18 16:31:38 +0000 |
| commit | c86351f37a1b9401b90065224f8c7c4d875c7bb6 (patch) | |
| tree | 1502ae58f7fe7b92cca55605094fc4b370ec2b03 /libstdc++-v3/include/std/future | |
| parent | ac3cd7cee064c7cb8694636f63fc80c546457a46 (diff) | |
| download | ppe42-gcc-c86351f37a1b9401b90065224f8c7c4d875c7bb6.tar.gz ppe42-gcc-c86351f37a1b9401b90065224f8c7c4d875c7bb6.zip | |
PR libstdc++/60564
* include/std/future (__future_base::_Task_state<>): Change
constructors to template functions using perfect forwarding.
(__create_task_state): Use decayed type as stored task.
(packaged_task::packaged_task(_Fn&&)): Forward instead of moving.
* testsuite/30_threads/packaged_task/60564.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208656 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/future')
| -rw-r--r-- | libstdc++-v3/include/std/future | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index ca3dacd5588..717ce7105df 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1285,9 +1285,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)> final : __future_base::_Task_state_base<_Res(_Args...)> { - _Task_state(_Fn&& __fn, const _Alloc& __a) - : _Task_state_base<_Res(_Args...)>(__a), _M_impl(std::move(__fn), __a) - { } + template<typename _Fn2> + _Task_state(_Fn2&& __fn, const _Alloc& __a) + : _Task_state_base<_Res(_Args...)>(__a), + _M_impl(std::forward<_Fn2>(__fn), __a) + { } private: virtual void @@ -1316,19 +1318,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct _Impl : _Alloc { - _Impl(_Fn&& __fn, const _Alloc& __a) - : _Alloc(__a), _M_fn(std::move(__fn)) { } + template<typename _Fn2> + _Impl(_Fn2&& __fn, const _Alloc& __a) + : _Alloc(__a), _M_fn(std::forward<_Fn2>(__fn)) { } _Fn _M_fn; } _M_impl; }; - template<typename _Signature, typename _Fn, typename _Alloc> - static shared_ptr<__future_base::_Task_state_base<_Signature>> - __create_task_state(_Fn&& __fn, const _Alloc& __a) - { - typedef __future_base::_Task_state<_Fn, _Alloc, _Signature> _State; - return std::allocate_shared<_State>(__a, std::move(__fn), __a); - } + template<typename _Signature, typename _Fn, typename _Alloc> + static shared_ptr<__future_base::_Task_state_base<_Signature>> + __create_task_state(_Fn&& __fn, const _Alloc& __a) + { + typedef typename decay<_Fn>::type _Fn2; + typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State; + return std::allocate_shared<_State>(__a, std::forward<_Fn>(__fn), __a); + } template<typename _Fn, typename _Alloc, typename _Res, typename... _Args> shared_ptr<__future_base::_Task_state_base<_Res(_Args...)>> @@ -1368,7 +1372,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __constrain_pkgdtask<packaged_task, _Fn>::__type> explicit packaged_task(_Fn&& __fn) - : packaged_task(allocator_arg, std::allocator<int>(), std::move(__fn)) + : packaged_task(allocator_arg, std::allocator<int>(), + std::forward<_Fn>(__fn)) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS |

