// // Copyright (c) 2024 Klemens Morgenstern (klemens.morgenstern@gmx.net) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_COBALT_NOOP_HPP #define BOOST_COBALT_NOOP_HPP #include #include namespace boost::cobalt { // tag::outline[] // This is a tag type allowing the creation of promises or generators without creating a coroutine. template struct noop { template constexpr noop(Args && ... args) noexcept(std::is_nothrow_constructible_v) : value(std::forward(args)...) { } // end::outline[] T value; constexpr static bool await_ready() {return true;} template constexpr static void await_suspend(std::coroutine_handle

) {} constexpr T await_resume() {return std::move(value);} // tag::outline[] }; // end::outline[] template<> struct noop { constexpr static bool await_ready() {return true;} template constexpr static void await_suspend(std::coroutine_handle

) {} constexpr static void await_resume() {} }; template noop( T &&) -> noop; template noop(const T & ) -> noop; noop() -> noop; } #endif //BOOST_COBALT_NOOP_HPP