mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
Fix the range_loop build
This commit is contained in:
parent
ac175b4e57
commit
a4da3e84ef
@ -55,9 +55,9 @@ namespace hints {
|
|||||||
///
|
///
|
||||||
/// This is the overload taking an arbitrary amount of args
|
/// This is the overload taking an arbitrary amount of args
|
||||||
template <typename... HintArgs>
|
template <typename... HintArgs>
|
||||||
struct from_args : std::common_type<identity<HintArgs...>> {};
|
struct from_args : std::common_type<signature_arg_t<HintArgs...>> {};
|
||||||
template <>
|
template <>
|
||||||
struct from_args<void> : std::common_type<identity<>> {};
|
struct from_args<void> : std::common_type<signature_arg_t<>> {};
|
||||||
} // namespace hints
|
} // namespace hints
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -32,12 +32,31 @@
|
|||||||
#define CONTINUABLE_DETAIL_OPERATIONS_ASYNC_HPP_INCLUDED
|
#define CONTINUABLE_DETAIL_OPERATIONS_ASYNC_HPP_INCLUDED
|
||||||
|
|
||||||
#include <continuable/continuable-base.hpp>
|
#include <continuable/continuable-base.hpp>
|
||||||
|
#include <continuable/detail/core/annotation.hpp>
|
||||||
|
#include <continuable/detail/core/base.hpp>
|
||||||
|
#include <continuable/detail/utility/identity.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace operations {
|
namespace operations {
|
||||||
|
template <typename... SignatureArgs, typename Callable, typename... Args>
|
||||||
|
auto make_async(signature_arg_t<SignatureArgs...>, Callable&& callable,
|
||||||
|
Args&&... args) {
|
||||||
|
|
||||||
|
auto continuation = [](auto&& promise) mutable { promise.set_value(); };
|
||||||
|
|
||||||
|
return base::attorney::create_from(std::move(continuation), //
|
||||||
|
signature_arg_t<Args...>{},
|
||||||
|
util::ownership{});
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Callable, typename... Args>
|
template <typename Callable, typename... Args>
|
||||||
auto async(Callable&& callable, Args&&... args) {
|
auto async(Callable&& callable, Args&&... args) {
|
||||||
|
using result_t = void;
|
||||||
|
using invoker_t =
|
||||||
|
decltype(base::decoration::invoker_of(identify<result_t>{}));
|
||||||
|
return make_async(invoker_t::hint(), std::forward<Callable>(callable),
|
||||||
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
} // namespace operations
|
} // namespace operations
|
||||||
|
|
||||||
|
|||||||
@ -154,17 +154,18 @@ auto loop(Callable&& callable, Args&&... args) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Callable, typename Begin>
|
template <typename Callable, typename Begin, typename End>
|
||||||
auto make_range_looper(Callable&& callable, Begin&& begin) {
|
auto make_range_looper(Callable&& callable, Begin&& begin, End&& end) {
|
||||||
return [callable = std::forward<Callable>(callable),
|
return [callable = std::forward<Callable>(callable),
|
||||||
begin = std::forward<Begin>(begin)](auto&& end) mutable {
|
begin = std::forward<Begin>(begin),
|
||||||
|
end = std::forward<End>(end)]() mutable {
|
||||||
return util::invoke(callable, begin)
|
return util::invoke(callable, begin)
|
||||||
.then([&begin, // begin stays valid over the `then`.
|
.then([&begin, &end]() mutable -> std::tuple<result<>> {
|
||||||
end = std::forward<decltype(end)>(end)]() mutable -> result<> {
|
// begin and end stays valid over the `then` here
|
||||||
if (++begin != end) {
|
if (++begin != end) {
|
||||||
return empty_result{};
|
return std::make_tuple(result<>(empty_result{}));
|
||||||
} else {
|
} else {
|
||||||
return make_result();
|
return std::make_tuple(make_result());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#define CONTINUABLE_OPERATIONS_LOOP_HPP_INCLUDED
|
#define CONTINUABLE_OPERATIONS_LOOP_HPP_INCLUDED
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/operations/loop.hpp>
|
#include <continuable/detail/operations/loop.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
@ -45,9 +46,9 @@ auto loop(Callable&& callable, Args&&... args) {
|
|||||||
|
|
||||||
template <typename Callable, typename Iterator>
|
template <typename Callable, typename Iterator>
|
||||||
auto range_loop(Callable&& callable, Iterator begin, Iterator end) {
|
auto range_loop(Callable&& callable, Iterator begin, Iterator end) {
|
||||||
auto looper = detail::operations::make_range_looper(
|
return detail::operations::loop( //
|
||||||
std::forward<Callable>(callable), begin);
|
detail::operations::make_range_looper(std::forward<Callable>(callable),
|
||||||
return detail::operations::loop(std::move(looper), end);
|
begin, end));
|
||||||
}
|
}
|
||||||
/// \}
|
/// \}
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user