Fix a build error in the result indexing

This commit is contained in:
Denis Blank 2018-02-26 18:33:26 +01:00
parent 786792f4f0
commit 331d642e5d
3 changed files with 29 additions and 65 deletions

View File

@ -40,15 +40,16 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
struct functional_io_service : asio::io_service { struct functional_io_service {
asio::io_context service_;
asio::ip::udp::resolver resolver_; asio::ip::udp::resolver resolver_;
functional_io_service() : resolver_(*this) { functional_io_service() : resolver_(service_) {
} }
auto post() const noexcept { auto trough_post() noexcept {
return [this](auto&& work) { return [&](auto&& work) mutable {
asio::io_service::post(std::forward<decltype(work)>(work)); service_.post(std::forward<decltype(work)>(work));
}; };
} }
@ -66,6 +67,10 @@ struct functional_io_service : asio::io_service {
}, },
std::move(host), std::move(service)); std::move(host), std::move(service));
} }
void run() {
service_.run();
}
}; };
int main(int, char**) { int main(int, char**) {
@ -74,10 +79,12 @@ int main(int, char**) {
functional_io_service service; functional_io_service service;
service.async_resolve("127.0.0.1", "daytime") service.async_resolve("127.0.0.1", "daytime")
.then([](udp::resolver::iterator iterator) { .then(
// ... [](udp::resolver::iterator iterator) {
return *iterator; // ...
}) return *iterator;
},
service.trough_post())
.then([](udp::endpoint /*endpoint*/) { .then([](udp::endpoint /*endpoint*/) {
// auto socket = std::make_shared<udp::socket>(service); // auto socket = std::make_shared<udp::socket>(service);
// socket->async_send_to() // socket->async_send_to()

View File

@ -45,6 +45,8 @@ namespace cti {
/// ///
/// \tparam Result The result of the converted continuable, this should align /// \tparam Result The result of the converted continuable, this should align
/// with the arguments that are passed to the callback. /// with the arguments that are passed to the callback.
///
/// \since 3.0.0
template <typename... Result> template <typename... Result>
class promisify { class promisify {
using helper = detail::convert::promisify_helper<Result...>; using helper = detail::convert::promisify_helper<Result...>;
@ -72,6 +74,7 @@ public:
/// - If exceptions are disabled the error type is copnverted to an /// - If exceptions are disabled the error type is copnverted to an
/// `std::error_conditon` and passed down to the error handler. /// `std::error_conditon` and passed down to the error handler.
/// ///
/// \since 3.0.0
template <typename Callable, typename... Args> template <typename Callable, typename... Args>
static auto from_asio(Callable&& callable, Args&&... args) { static auto from_asio(Callable&& callable, Args&&... args) {
return helper::template from<detail::convert::promisify_asio>( return helper::template from<detail::convert::promisify_asio>(

View File

@ -131,12 +131,7 @@ struct result_relocator_mapper {
void traverse(traversal::container_category_tag<false, false>, Index* index, void traverse(traversal::container_category_tag<false, false>, Index* index,
Result* result) { Result* result) {
auto id = traits::identity<std::decay_t<decltype(index)>>{};
auto i = is_indexed_continuable<std::decay_t<decltype(index)>>::value;
auto res = traits::is_invocable<Evaluator, Index, Result>{};
evaluator(index, result); evaluator(index, result);
traverse_one(traits::is_invocable<Evaluator, Index, Result>{}, index, traverse_one(traits::is_invocable<Evaluator, Index, Result>{}, index,
result); result);
} }
@ -216,48 +211,22 @@ constexpr void relocate_index_pack(Relocator&& relocator, Index* index,
mapper.traverse(tag, index, target); mapper.traverse(tag, index, target);
} }
/* struct index_relocator {
template <typename T> template <typename Index, typename Target,
auto remape_container(traversal::container_category_tag<false, true>, std::enable_if_t<is_indexed_continuable<Index>::value>* = nullptr>
T&& container) { auto operator()(Index* index, Target* target) const noexcept {
} // Assign the address of the target to the indexed continuable
index->target = target;
template <bool IsTupleLike, typename T> }
auto remape_container(traversal::container_category_tag<true, IsTupleLike>, };
T&& container) {
}
template <
typename T,
typename Category = traversal::container_category_of_t<std::decay_t<T>>,
std::enable_if_t<Category::value>* = nullptr>
auto operator()(T&& container) {
return remape_container(std::forward<T>(container));
}
*/
} // namespace remapping } // namespace remapping
struct c {};
template <typename C, typename... Args>
struct loc {};
struct runtime_insertion {
std::size_t begin, end;
};
template <typename... Args>
struct future_result {
std::tuple<Args...> result_;
};
} // namespace detail } // namespace detail
} // namespace cti } // namespace cti
using namespace cti::detail::remapping;
int main(int, char**) { int main(int, char**) {
using namespace cti::detail; using namespace cti::detail;
using namespace remapping;
std::vector<int> vc{1, 2, 3}; std::vector<int> vc{1, 2, 3};
@ -269,22 +238,7 @@ int main(int, char**) {
auto r = create_result_pack(std::move(p)); auto r = create_result_pack(std::move(p));
auto i = create_index_pack(std::move(p)); auto i = create_index_pack(std::move(p));
relocate_index_pack(index_relocator{}, &i, &r);
/*relocate_index_pack(
[](auto index, auto result)
-> std::enable_if_t<is_indexed_continuable<
std::remove_pointer_t<std::decay_t<decltype(index)>>>::value> {
// Assign the address of the target to the indexed continuable
index->target = result;
return;
},
&i, &r);*/
auto t = [](auto&&...) {};
promisify<int>::from(t, "");
return 0; return 0;
} }