diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index 63d0305..b5292c0 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -895,6 +895,19 @@ constexpr auto make_exceptional_continuable(Exception&& exception) { std::move(exception)); }); } + +template +auto recover(Args&&... args) { + // TODO +} + +inline auto rethrow(exception_t exception) { + // TODO +} + +inline constexpr auto cancel() { + // TODO +} /// \} } // namespace cti diff --git a/include/continuable/detail/utility/expected.hpp b/include/continuable/continuable-expected.hpp similarity index 64% rename from include/continuable/detail/utility/expected.hpp rename to include/continuable/continuable-expected.hpp index 572760c..98fbef8 100644 --- a/include/continuable/detail/utility/expected.hpp +++ b/include/continuable/continuable-expected.hpp @@ -28,24 +28,20 @@ SOFTWARE. **/ -#ifndef CONTINUABLE_DETAIL_EXPECTED_HPP_INCLUDED -#define CONTINUABLE_DETAIL_EXPECTED_HPP_INCLUDED +#ifndef CONTINUABLE_EXPECTED_HPP_INCLUDED +#define CONTINUABLE_EXPECTED_HPP_INCLUDED #include #include #include -#include #include namespace cti { -namespace detail { -namespace container { /// A class similar to the one in the expected proposal, -/// however it is capable of carrying an exception_ptr if -/// exceptions are used. +/// however it's capable of carrying an exception_t. template class expected { - flat_variant variant_; + detail::container::flat_variant variant_; public: explicit expected() = default; @@ -76,6 +72,9 @@ public: variant_ = std::move(exception); } + bool is_empty() { + return variant_.is_empty(); + } bool is_value() const noexcept { return variant_.template is(); } @@ -107,56 +106,6 @@ public: return get_value(); } }; - -namespace detail { -struct void_guard_tag {}; - -template -struct expected_result_trait; -template <> -struct expected_result_trait> { - using expected_type = expected; - - static constexpr void_guard_tag wrap() noexcept { - return {}; - } - static void unwrap(expected_type&& e) { - assert(e.is_value()); - (void)e; - } -}; -template -struct expected_result_trait> { - using expected_type = expected; - - static auto wrap(T arg) { - return std::move(arg); - } - static auto unwrap(expected_type&& e) { - assert(e.is_value()); - return std::move(e.get_value()); - } -}; -template -struct expected_result_trait> { - using expected_type = expected>; - - static auto wrap(First first, Second second, Rest... rest) { - return std::make_tuple(std::move(first), std::move(second), - std::move(rest)...); - } - static auto unwrap(expected_type&& e) { - assert(e.is_value()); - return std::move(e.get_value()); - } -}; -} // namespace detail - -template -using expected_result_trait_t = detail::expected_result_trait{}))>; -} // namespace container -} // namespace detail } // namespace cti -#endif // CONTINUABLE_DETAIL_EXPECTED_HPP_INCLUDED +#endif // CONTINUABLE_EXPECTED_HPP_INCLUDED diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index 9e02b98..deeeb13 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/include/continuable/detail/other/coroutines.hpp b/include/continuable/detail/other/coroutines.hpp index c5c2d30..c07e7f2 100644 --- a/include/continuable/detail/other/coroutines.hpp +++ b/include/continuable/detail/other/coroutines.hpp @@ -35,11 +35,12 @@ #include #include #include +#include #include #include #include #include -#include +#include #include #include diff --git a/include/continuable/detail/utility/expected-traits.hpp b/include/continuable/detail/utility/expected-traits.hpp new file mode 100644 index 0000000..2da91bf --- /dev/null +++ b/include/continuable/detail/utility/expected-traits.hpp @@ -0,0 +1,93 @@ + +/* + + /~` _ _ _|_. _ _ |_ | _ + \_,(_)| | | || ||_|(_||_)|(/_ + + https://github.com/Naios/continuable + v3.0.0 + + Copyright(c) 2015 - 2018 Denis Blank + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files(the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and / or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +**/ + +#ifndef CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED +#define CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED + +#include +#include +#include +#include + +namespace cti { +namespace detail { +namespace container { +namespace detail { +struct void_guard_tag {}; + +template +struct expected_result_trait; +template <> +struct expected_result_trait> { + using expected_type = expected; + + static constexpr void_guard_tag wrap() noexcept { + return {}; + } + static void unwrap(expected_type&& e) { + assert(e.is_value()); + (void)e; + } +}; +template +struct expected_result_trait> { + using expected_type = expected; + + static auto wrap(T arg) { + return std::move(arg); + } + static auto unwrap(expected_type&& e) { + assert(e.is_value()); + return std::move(e.get_value()); + } +}; +template +struct expected_result_trait> { + using expected_type = expected>; + + static auto wrap(First first, Second second, Rest... rest) { + return std::make_tuple(std::move(first), std::move(second), + std::move(rest)...); + } + static auto unwrap(expected_type&& e) { + assert(e.is_value()); + return std::move(e.get_value()); + } +}; +} // namespace detail + +template +using expected_result_trait_t = detail::expected_result_trait{}))>; +} // namespace container +} // namespace detail +} // namespace cti + +#endif // CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED