diff --git a/include/unifex/when_all_range.hpp b/include/unifex/when_all_range.hpp index dbc48d6f..795d9482 100644 --- a/include/unifex/when_all_range.hpp +++ b/include/unifex/when_all_range.hpp @@ -276,9 +276,14 @@ struct _sender::type final { using sender_value_type = unifex::sender_single_value_result_t>; - explicit type(std::vector&& senders) noexcept( - std::is_nothrow_move_constructible_v>) - : senders_(std::move(senders)) {} + explicit type( + std::vector&& senders, + instruction_ptr + returnAddress) noexcept(std:: + is_nothrow_move_constructible_v< + std::vector>) + : senders_(std::move(senders)) + , returnAddress_(returnAddress) {} template < template @@ -333,24 +338,36 @@ struct _sender::type final { } } + friend instruction_ptr + tag_invoke(tag_t, const type& sender) noexcept { + return sender.returnAddress_; + } + std::vector senders_; + instruction_ptr returnAddress_; }; namespace _cpo { struct _fn final { +private: + template + using sender_from_iterator_t = + typename std::iterator_traits::value_type; + +public: template(typename Sender) // (requires(unifex::sender)) // auto operator()(std::vector senders) const { - return _when_all_range::sender(std::move(senders)); + return _when_all_range::sender( + std::move(senders), instruction_ptr::read_return_address()); } template - auto operator()(Iterator first, Iterator last) const -> decltype(operator()( - std::vector::value_type>{ - first, last})) { - return operator()( - std::vector::value_type>{ - first, last}); + auto operator()(Iterator first, Iterator last) const + -> _when_all_range::sender> { + return _when_all_range::sender>( + std::vector>(first, last), + instruction_ptr::read_return_address()); } }; } // namespace _cpo