-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<future>
cleanups
#3940
<future>
cleanups
#3940
Changes from 4 commits
86b16ce
f8b81b0
8cf4877
f6fc01f
e8b528c
9327f04
afd9d6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,15 +469,6 @@ public: | |
using _Mybase = _Associated_state<_Ret>; | ||
using _Mydel = typename _Mybase::_Mydel; | ||
|
||
template <class _Fty2> | ||
_Packaged_state(const _Fty2& _Fnarg) : _Fn(_Fnarg) {} | ||
|
||
#if _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
template <class _Fty2, class _Alloc> | ||
_Packaged_state(const _Fty2& _Fnarg, const _Alloc& _Al, _Mydel* _Dp) | ||
: _Mybase(_Dp), _Fn(allocator_arg, _Al, _Fnarg) {} | ||
#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
|
||
template <class _Fty2> | ||
_Packaged_state(_Fty2&& _Fnarg) : _Fn(_STD forward<_Fty2>(_Fnarg)) {} | ||
|
||
|
@@ -507,7 +498,7 @@ public: | |
_CATCH_END | ||
} | ||
|
||
const function<_Ret(_ArgTypes...)>& _Get_fn() { | ||
const auto& _Get_fn() const { | ||
return _Fn; | ||
} | ||
|
||
|
@@ -522,15 +513,6 @@ public: | |
using _Mybase = _Associated_state<_Ret*>; | ||
using _Mydel = typename _Mybase::_Mydel; | ||
|
||
template <class _Fty2> | ||
_Packaged_state(const _Fty2& _Fnarg) : _Fn(_Fnarg) {} | ||
|
||
#if _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
template <class _Fty2, class _Alloc> | ||
_Packaged_state(const _Fty2& _Fnarg, const _Alloc& _Al, _Mydel* _Dp) | ||
: _Mybase(_Dp), _Fn(allocator_arg, _Al, _Fnarg) {} | ||
#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
|
||
template <class _Fty2> | ||
_Packaged_state(_Fty2&& _Fnarg) : _Fn(_STD forward<_Fty2>(_Fnarg)) {} | ||
|
||
|
@@ -560,7 +542,7 @@ public: | |
_CATCH_END | ||
} | ||
|
||
const function<_Ret&(_ArgTypes...)>& _Get_fn() { | ||
const auto& _Get_fn() const { | ||
return _Fn; | ||
} | ||
|
||
|
@@ -575,15 +557,6 @@ public: | |
using _Mybase = _Associated_state<int>; | ||
using _Mydel = typename _Mybase::_Mydel; | ||
|
||
template <class _Fty2> | ||
_Packaged_state(const _Fty2& _Fnarg) : _Fn(_Fnarg) {} | ||
|
||
#if _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
template <class _Fty2, class _Alloc> | ||
_Packaged_state(const _Fty2& _Fnarg, const _Alloc& _Al, _Mydel* _Dp) | ||
: _Mybase(_Dp), _Fn(allocator_arg, _Al, _Fnarg) {} | ||
#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT | ||
|
||
template <class _Fty2> | ||
_Packaged_state(_Fty2&& _Fnarg) : _Fn(_STD forward<_Fty2>(_Fnarg)) {} | ||
|
||
|
@@ -615,7 +588,7 @@ public: | |
_CATCH_END | ||
} | ||
|
||
const function<void(_ArgTypes...)>& _Get_fn() { | ||
const auto& _Get_fn() const { | ||
return _Fn; | ||
} | ||
|
||
|
@@ -1285,12 +1258,13 @@ class packaged_task; // not defined | |
template <class _Ret, class... _ArgTypes> | ||
class packaged_task<_Ret(_ArgTypes...)> { | ||
// class that defines an asynchronous provider that returns the result of a call to a function object | ||
public: | ||
private: | ||
using _Ptype = typename _P_arg_type<_Ret>::type; | ||
using _MyPromiseType = _Promise<_Ptype>; | ||
using _MyStateManagerType = _State_manager<_Ptype>; | ||
using _MyStateType = _Packaged_state<_Ret(_ArgTypes...)>; | ||
|
||
public: | ||
packaged_task() = default; | ||
|
||
template <class _Fty2, enable_if_t<!is_same_v<_Remove_cvref_t<_Fty2>, packaged_task>, int> = 0> | ||
|
@@ -1347,10 +1321,9 @@ public: | |
} | ||
|
||
void reset() { // reset to newly constructed state | ||
_MyStateManagerType& _State = _MyPromise._Get_state_for_set(); | ||
_MyStateType* _MyState = static_cast<_MyStateType*>(_State._Ptr()); | ||
function<_Ret(_ArgTypes...)> _Fnarg = _MyState->_Get_fn(); | ||
_MyPromiseType _New_promise(new _MyStateType(_Fnarg)); | ||
_MyStateManagerType& _State = _MyPromise._Get_state_for_set(); | ||
_MyStateType* _MyState = static_cast<_MyStateType*>(_State._Ptr()); | ||
_MyPromiseType _New_promise(new _MyStateType(_MyState->_Get_fn())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm 80% sure about this change; or was the extra copy construction intentional here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe it was intentional. |
||
_MyPromise._Get_state()._Abandon(); | ||
_MyPromise._Swap(_New_promise); | ||
} | ||
|
@@ -1385,14 +1358,13 @@ void swap(packaged_task<_Ty>& _Left, packaged_task<_Ty>& _Right) noexcept { | |
} | ||
|
||
template <class... _Types, size_t... _Indices> | ||
auto _Invoke_stored_explicit(tuple<_Types...>&& _Tuple, index_sequence<_Indices...>) -> decltype(_STD invoke( | ||
_STD get<_Indices>(_STD move(_Tuple))...)) { // invoke() a tuple with explicit parameter ordering | ||
decltype(auto) _Invoke_stored_explicit( | ||
tuple<_Types...>&& _Tuple, index_sequence<_Indices...>) { // invoke() a tuple with explicit parameter ordering | ||
return _STD invoke(_STD get<_Indices>(_STD move(_Tuple))...); | ||
} | ||
|
||
template <class... _Types> | ||
auto _Invoke_stored(tuple<_Types...>&& _Tuple) | ||
-> decltype(_Invoke_stored_explicit(_STD move(_Tuple), index_sequence_for<_Types...>{})) { // invoke() a tuple | ||
decltype(auto) _Invoke_stored(tuple<_Types...>&& _Tuple) { // invoke() a tuple | ||
Comment on lines
-1394
to
+1367
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change requested: The difference here is that |
||
return _Invoke_stored_explicit(_STD move(_Tuple), index_sequence_for<_Types...>{}); | ||
} | ||
|
||
|
@@ -1419,7 +1391,7 @@ public: | |
_Fake_no_copy_callable_adapter& operator=(const _Fake_no_copy_callable_adapter&) = delete; | ||
_Fake_no_copy_callable_adapter& operator=(_Fake_no_copy_callable_adapter&&) = delete; | ||
|
||
auto operator()() -> decltype(_Invoke_stored(_STD move(_STD declval<_Storaget&>()))) { | ||
decltype(auto) operator()() { | ||
return _Invoke_stored(_STD move(_Storage)); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are fully replaceable with their
_Fty2&&
versions