cobalt::awaitable c++ concept
cobalt::awaitable 是一个 c++ concept,要求一个类型必须是一个 awaitable 类型,即可 co_await 表达式。
4月15日 - fayige.top
显然,cobalt::promise, cobalt::generator 都满足 cobalt::awaitable
c++ boost::cobalt::awaitable 例子
文件名:cobalt_awaitable.cpp
#include <boost/cobalt.hpp> #include <iostream> namespace cobalt = boost::cobalt; template <cobalt::awaitable type_t> class test { }; cobalt::main co_main(int argc, char * argv[]) { test<cobalt::promise<int>>{}; test<cobalt::generator<float>>{}; std::cout << "欢迎收看,谢谢!" << std::endl; co_return 0; }
Copyright 2024 fayige.top
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)