From 9ceee7664760f5da64be7c9466c9420e8f4f621e Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Sat, 8 Dec 2018 17:52:22 +0100 Subject: [PATCH] Fix an issue with the is_ready overload --- include/continuable/detail/connection/connection-all.hpp | 8 ++++---- include/continuable/detail/core/base.hpp | 4 ++-- include/continuable/detail/utility/util.hpp | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/continuable/detail/connection/connection-all.hpp b/include/continuable/detail/connection/connection-all.hpp index 7180d30..164437f 100644 --- a/include/continuable/detail/connection/connection-all.hpp +++ b/include/continuable/detail/connection/connection-all.hpp @@ -99,11 +99,11 @@ class result_submitter } template - void operator()(exception_arg_t tag, exception_t error) && { + void operator()(exception_arg_t tag, exception_t exception) && { // We never complete the connection, but we forward the first error // which was raised. std::call_once(me->flag_, std::move(me->callback_), tag, - std::move(error)); + std::move(exception)); } }; @@ -168,8 +168,8 @@ struct connection_finalizer { all::result_submitter, std::decay_t>; - // Create the shared state which holds the result and the final - // callback + // Create the shared state which holds the result + // and the final callback auto state = std::make_shared( std::forward(callback), std::move(result)); diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index 1ffbb82..4a7d020 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -757,12 +757,12 @@ struct chained_continuation, HandleResults, // TODO Detect statically whether we have a raw ready continuable here // Check whether the continuation is ready - bool const is_ready = continuation_(is_ready_arg_t{}); + bool const is_ready = util::as_const(continuation_)(is_ready_arg_t{}); if (is_ready) { // Invoke the proxy callback directly with the result to // avoid a potential type erasure. // traits::unpack(std::move(proxy), - // std::move(continuation_)(query_arg_t{})); + std::move(continuation_)(query_arg_t{}); } else { // Invoke the continuation with a proxy callback. // The proxy callback is responsible for passing diff --git a/include/continuable/detail/utility/util.hpp b/include/continuable/detail/utility/util.hpp index 5620d2e..004660b 100644 --- a/include/continuable/detail/utility/util.hpp +++ b/include/continuable/detail/utility/util.hpp @@ -167,6 +167,12 @@ constexpr auto invoke(Type T::*member, Self&& self, Args&&... args) noexcept( return (std::forward(self)->*member)(std::forward(args)...); } +/// Returns a constant view on the object +template +constexpr std::add_const_t& as_const(T& object) noexcept { + return object; +} + // Class for making child classes non copyable struct non_copyable { constexpr non_copyable() = default;