diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index 4045179..28bb73f 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -90,7 +90,9 @@ using is_continuable = detail::base::is_continuable; /// /// \since 1.0.0 template -class continuable_base { +class continuable_base + : public detail::annotation_trait::template // + annotation_base> { /// \cond false using ownership = detail::util::ownership; @@ -99,11 +101,6 @@ class continuable_base { friend class continuable_base; friend struct detail::base::attorney; - // The materializer which is used when this continuable_base is an - // expression template such that is_connection_strategy::value - // holds for the Annotation. - using materializer = detail::connection::materializer; - // The continuation type or intermediate result Data data_; // The transferable state which represents the validity of the object @@ -565,6 +562,7 @@ public: detail::base::finalize_continuation(std::move(*this)); } +#ifdef CONTINUABLE_HAS_DOXYGEN /// Materializes the continuation expression template and finishes /// the current applied strategy. /// @@ -588,9 +586,8 @@ public: /// on conversion. /// /// \since 4.0.0 - auto finish() && { - return materializer::apply(std::move(*this)); - } + unspecified finish() &&; +#endif // CONTINUABLE_HAS_DOXYGEN #ifdef CONTINUABLE_HAS_DOXYGEN /// Returns true if the continuable_base will resolve its promise diff --git a/include/continuable/detail/connection/connection-all.hpp b/include/continuable/detail/connection/connection-all.hpp index 27e084b..7180d30 100644 --- a/include/continuable/detail/connection/connection-all.hpp +++ b/include/continuable/detail/connection/connection-all.hpp @@ -40,8 +40,8 @@ #include #include #include -#include #include +#include #include #include @@ -164,7 +164,6 @@ struct connection_finalizer { return base::attorney::create_from( [result = std::move(result)](auto&& callback) mutable { - using submitter_t = all::result_submitter, std::decay_t>; @@ -186,6 +185,12 @@ struct connection_finalizer { } }; } // namespace connection + +/// Specialization for a connection annotation +template <> +struct annotation_trait + : connection::connection_annotation_trait {}; + } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection/connection-any.hpp b/include/continuable/detail/connection/connection-any.hpp index ec601b8..3238a4f 100644 --- a/include/continuable/detail/connection/connection-any.hpp +++ b/include/continuable/detail/connection/connection-any.hpp @@ -40,8 +40,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -177,7 +177,6 @@ struct connection_finalizer { return base::attorney::create_from( [connection = std::forward(connection)](auto&& callback) mutable { - using submitter_t = any::any_result_submitter>; @@ -193,6 +192,12 @@ struct connection_finalizer { } }; } // namespace connection + + /// Specialization for a connection annotation +template <> +struct annotation_trait + : connection::connection_annotation_trait {}; + } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection/connection-seq.hpp b/include/continuable/detail/connection/connection-seq.hpp index fa5ade3..7736982 100644 --- a/include/continuable/detail/connection/connection-seq.hpp +++ b/include/continuable/detail/connection/connection-seq.hpp @@ -160,6 +160,12 @@ struct connection_finalizer { } }; } // namespace connection + +/// Specialization for a connection annotation +template <> +struct annotation_trait + : connection::connection_annotation_trait {}; + } // namespace detail } // namespace cti diff --git a/include/continuable/detail/connection/connection.hpp b/include/continuable/detail/connection/connection.hpp index 1fde0c8..44de863 100644 --- a/include/continuable/detail/connection/connection.hpp +++ b/include/continuable/detail/connection/connection.hpp @@ -124,33 +124,27 @@ auto connect(Strategy strategy, continuable_base&& left, template struct connection_finalizer; -/// Finalizes the connection logic of a given connection -template -auto finalize_connection(continuable_base&& continuation) { - using finalizer = connection_finalizer; +struct connection_annotation_trait { + template + struct annotation_base; + template + struct annotation_base> { + /// Finalizes the connection logic of a given connection + auto finish() && { + using continuable_t = continuable_base; + auto&& continuation = std::move(*static_cast(this)); - util::ownership ownership = base::attorney::ownership_of(continuation); - auto connection = base::attorney::consume(std::move(continuation)); + using finalizer = connection_finalizer; - // Return a new continuable which - return finalizer::finalize(std::move(connection), std::move(ownership)); -} + util::ownership ownership = base::attorney::ownership_of(continuation); + auto connection = base::attorney::consume(std::move(continuation)); -/// A base class from which the continuable may inherit in order to -/// provide a materializer method which will finalize an oustanding strategy. -template -struct materializer { - static constexpr auto&& apply(Continuable&& continuable) { - return std::move(continuable); - } -}; -template -struct materializer, - std::enable_if_t::value>> { + // Return a new continuable which + return finalizer::finalize(std::move(connection), std::move(ownership)); + } + }; - static constexpr auto apply(continuable_base&& continuable) { - return finalize_connection(std::move(continuable)); - } + using is_concrete = std::false_type; }; class prepare_continuables { diff --git a/include/continuable/detail/core/annotation.hpp b/include/continuable/detail/core/annotation.hpp index 0decc6d..f7e64d4 100644 --- a/include/continuable/detail/core/annotation.hpp +++ b/include/continuable/detail/core/annotation.hpp @@ -43,9 +43,16 @@ struct annotation_trait; /// Specialization for a present signature hint template struct annotation_trait> { - using is_concrete_hint = std::true_type; - using hint_t = traits::identity; - using is_materialized = std::true_type; + template + struct annotation_base { + Continuable&& finish() { + return std::move(*static_cast(this)); + } + + static constexpr bool is_concrete = true; + }; + + using is_concrete = std::true_type; }; namespace hints {