main.hpp 895 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_COBALT_MAIN_HPP
  6. #define BOOST_COBALT_MAIN_HPP
  7. #include <boost/cobalt/concepts.hpp>
  8. #include <boost/cobalt/this_coro.hpp>
  9. #include <boost/asio/io_context.hpp>
  10. #include <coroutine>
  11. #include <optional>
  12. namespace boost::cobalt
  13. {
  14. namespace detail { struct main_promise; }
  15. class main;
  16. }
  17. auto co_main(int argc, char * argv[]) -> boost::cobalt::main;
  18. namespace boost::cobalt
  19. {
  20. class main
  21. {
  22. detail::main_promise * promise;
  23. main(detail::main_promise * promise) : promise(promise) {}
  24. friend auto ::co_main(int argc, char * argv[]) -> boost::cobalt::main;
  25. friend struct detail::main_promise;
  26. };
  27. }
  28. #include <boost/cobalt/detail/main.hpp>
  29. #endif //BOOST_COBALT_MAIN_HPP