mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
use attorney::create_from and remove unnecessary conditional_t
This commit is contained in:
parent
4f220df1d7
commit
fb7074cc87
@ -30,6 +30,8 @@
|
|||||||
#ifndef CONTINUABLE_DETAIL_ASIO_HPP_INCLUDED
|
#ifndef CONTINUABLE_DETAIL_ASIO_HPP_INCLUDED
|
||||||
#define CONTINUABLE_DETAIL_ASIO_HPP_INCLUDED
|
#define CONTINUABLE_DETAIL_ASIO_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <continuable/detail/core/base.hpp>
|
||||||
|
|
||||||
#if defined(ASIO_STANDALONE)
|
#if defined(ASIO_STANDALONE)
|
||||||
#include <asio/async_result.hpp>
|
#include <asio/async_result.hpp>
|
||||||
#include <asio/error_code.hpp>
|
#include <asio/error_code.hpp>
|
||||||
@ -71,8 +73,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CTI_DETAIL_ASIO_HAS_NO_INTEGRATION)
|
#if defined(CTI_DETAIL_ASIO_HAS_NO_INTEGRATION)
|
||||||
#error \
|
#error "First-class ASIO support for continuable requires the form of "\
|
||||||
"First-class ASIO support for continuable requires the form of "\
|
|
||||||
"`async_result` with an `initiate` static member function, which was added " \
|
"`async_result` with an `initiate` static member function, which was added " \
|
||||||
"in standalone ASIO 1.13.0 and Boost ASIO 1.70. Older versions can be " \
|
"in standalone ASIO 1.13.0 and Boost ASIO 1.70. Older versions can be " \
|
||||||
"integrated manually with `cti::promisify`."
|
"integrated manually with `cti::promisify`."
|
||||||
@ -141,26 +142,15 @@ struct initiate_make_continuable;
|
|||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
||||||
using is_void_cti_t = std::integral_constant<bool, sizeof...(Args) == 0>;
|
|
||||||
|
|
||||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||||
using erased_return_type =
|
using erased_return_type = cti::continuable<Args...>;
|
||||||
std::conditional_t<is_void_cti_t::value, cti::continuable<>,
|
|
||||||
cti::continuable<Args...>>;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Continuation, typename IsVoid = is_void_cti_t>
|
template <typename Continuation>
|
||||||
auto operator()(Continuation&& continuation,
|
auto operator()(Continuation&& continuation) {
|
||||||
std::enable_if_t<IsVoid::value>* = 0) {
|
return detail::base::attorney::create_from(
|
||||||
return cti::make_continuable<void>(
|
std::forward<Continuation>(continuation), detail::identity<Args...>{},
|
||||||
std::forward<Continuation>(continuation));
|
detail::util::ownership{});
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Continuation, typename IsVoid = is_void_cti_t>
|
|
||||||
auto operator()(Continuation&& continuation,
|
|
||||||
std::enable_if_t<!IsVoid::value>* = 0) {
|
|
||||||
return cti::make_continuable<Args...>(
|
|
||||||
std::forward<Continuation>(continuation));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user