join.hpp 823 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // Copyright (c) 2022 Klemens Morgenstern ([email protected])
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_COBALT_JOIN_HPP
  8. #define BOOST_COBALT_JOIN_HPP
  9. #include <boost/cobalt/concepts.hpp>
  10. #include <boost/cobalt/detail/join.hpp>
  11. namespace boost::cobalt
  12. {
  13. template<awaitable ... Promise>
  14. auto join(Promise && ... p)
  15. {
  16. return detail::join_variadic_impl<Promise ...>(
  17. static_cast<Promise&&>(p)...);
  18. }
  19. template<typename PromiseRange>
  20. requires awaitable<std::decay_t<decltype(*std::declval<PromiseRange>().begin())>>
  21. auto join(PromiseRange && p)
  22. {
  23. return detail::join_ranged_impl<PromiseRange>{static_cast<PromiseRange&&>(p)};
  24. }
  25. }
  26. #endif //BOOST_COBALT_JOIN_HPP