This pull request fixes the problem that coro::task<int&&> cannot be constructed.
When return_type is reference_type, the promise::result() always returns return_type
When return_type is not reference_type, the promise::result() either returns const return_type& by decltype(m_return_value.value()) or returns return_type&& by decltype(std::move(m_return_value.value())
The pull request also reduces the size of promise when return_type is reference type. The underlying held type for reference return type is changed from std::optional<std::reference_wrapper<std::remove_reference<return_type>>> to std::remove_reference<return_type>*. The typical size of std::optional<std::reference_wrapper<int>> is 16 and the size of pointer is typically 8.
This pull request fixes the problem that
coro::task<int&&>
cannot be constructed.When
return_type
is reference_type, thepromise::result()
always returnsreturn_type
Whenreturn_type
is not reference_type, thepromise::result()
either returnsconst return_type&
bydecltype(m_return_value.value())
or returnsreturn_type&&
bydecltype(std::move(m_return_value.value())
The pull request also reduces the size of
promise
whenreturn_type
is reference type. The underlying held type for reference return type is changed fromstd::optional<std::reference_wrapper<std::remove_reference<return_type>>>
tostd::remove_reference<return_type>*
. The typical size ofstd::optional<std::reference_wrapper<int>>
is 16 and the size of pointer is typically 8.