| 1 | // Copyright (c) 2023 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_LEAF_HPP |
| 6 | #define BOOST_COBALT_LEAF_HPP |
| 7 | |
| 8 | #include <boost/cobalt/detail/leaf.hpp> |
| 9 | |
| 10 | #include <boost/leaf/config.hpp> |
| 11 | #include <boost/leaf/handle_errors.hpp> |
| 12 | |
| 13 | namespace boost::cobalt |
| 14 | { |
| 15 | |
| 16 | template<awaitable TryAwaitable, typename ... H > |
| 17 | auto try_catch(TryAwaitable && try_coro, H && ... h ) |
| 18 | { |
| 19 | return detail::try_catch_awaitable< |
| 20 | std::decay_t<decltype(detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)))>, H...> |
| 21 | { |
| 22 | detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)), |
| 23 | {std::forward<H>(h)...} |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | template<awaitable TryAwaitable, typename ... H > |
| 28 | auto try_handle_all(TryAwaitable && try_coro, H && ... h ) |
| 29 | { |
| 30 | return detail::try_handle_all_awaitable< |
| 31 | std::decay_t<decltype(detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)))>, H...> |
| 32 | { |
| 33 | detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)), |
| 34 | {std::forward<H>(h)...} |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | template<awaitable TryAwaitable, typename ... H > |
| 39 | auto try_handle_some(TryAwaitable && try_coro, H && ... h ) |
| 40 | { |
| 41 | return detail::try_handle_some_awaitable< |
| 42 | std::decay_t<decltype(detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)))>, H...> |
| 43 | { |
| 44 | detail::get_awaitable_type(std::forward<TryAwaitable>(try_coro)), |
| 45 | {std::forward<H>(h)...} |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | |
| 51 | #endif //BOOST_COBALT_LEAF_HPP |
| 52 | |