X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Foutcome%2Fbasic_outcome.hpp;fp=ceph%2Fsrc%2Fboost%2Fboost%2Foutcome%2Fbasic_outcome.hpp;h=99f44831d69e72b8a693707437b604578081fafb;hb=f67539c23b11f3b8a2ecaeeddf7a403ae1c442a8;hp=3bb5dc656700d8855678540c2173dadc2d8fc51e;hpb=64a4c04e6850c6d9086e4c37f57c4eada541b05e;p=ceph.git diff --git a/ceph/src/boost/boost/outcome/basic_outcome.hpp b/ceph/src/boost/boost/outcome/basic_outcome.hpp index 3bb5dc656..99f44831d 100644 --- a/ceph/src/boost/boost/outcome/basic_outcome.hpp +++ b/ceph/src/boost/boost/outcome/basic_outcome.hpp @@ -1,5 +1,5 @@ /* A less simple result type -(C) 2017-2019 Niall Douglas (20 commits) +(C) 2017-2020 Niall Douglas (20 commits) File Created: June 2017 @@ -44,8 +44,7 @@ DEALINGS IN THE SOFTWARE. BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN -template // -BOOST_OUTCOME_REQUIRES(trait::type_can_be_used_in_basic_result

&& (std::is_void

::value || std::is_default_constructible

::value)) // +template // class basic_outcome; namespace detail @@ -87,7 +86,8 @@ namespace detail static constexpr bool enable_exception_converting_constructor = // implicit_constructors_enabled // && !is_in_place_type_t>::value // not in place construction - && !detail::is_implicitly_constructible && !detail::is_implicitly_constructible && detail::is_implicitly_constructible; + && !detail::is_implicitly_constructible && !detail::is_implicitly_constructible && + detail::is_implicitly_constructible; // Predicate for the error + exception converting constructor to be available. template @@ -99,51 +99,66 @@ namespace detail // Predicate for the converting copy constructor from a compatible outcome to be available. template - static constexpr bool enable_compatible_conversion = // - (std::is_void::value || detail::is_explicitly_constructible::value_type>) // if our value types are constructible - &&(std::is_void::value || detail::is_explicitly_constructible::error_type>) // if our error types are constructible - &&(std::is_void::value || detail::is_explicitly_constructible::exception_type>) // if our exception types are constructible + static constexpr bool enable_compatible_conversion = // + (std::is_void::value || + detail::is_explicitly_constructible::value_type>) // if our value types are constructible + &&(std::is_void::value || + detail::is_explicitly_constructible::error_type>) // if our error types are constructible + &&(std::is_void::value || + detail::is_explicitly_constructible::exception_type>) // if our exception types are constructible ; // Predicate for the converting constructor from a make_error_code() of the input to be available. template - static constexpr bool enable_make_error_code_compatible_conversion = // - trait::is_error_code_available>::value // if error type has an error code - && !enable_compatible_conversion // and the normal compatible conversion is not available - && (std::is_void::value || detail::is_explicitly_constructible::value_type>) // and if our value types are constructible - &&detail::is_explicitly_constructible::type> // and our error type is constructible from a make_error_code() - && (std::is_void::value || detail::is_explicitly_constructible::exception_type>); // and our exception types are constructible + static constexpr bool enable_make_error_code_compatible_conversion = // + trait::is_error_code_available>::value // if error type has an error code + && !enable_compatible_conversion // and the normal compatible conversion is not available + && (std::is_void::value || + detail::is_explicitly_constructible::value_type>) // and if our value types are constructible + &&detail::is_explicitly_constructible::type> // and our error type is constructible from a make_error_code() + && (std::is_void::value || + detail::is_explicitly_constructible::exception_type>); // and our exception types are constructible // Predicate for the implicit converting inplace constructor from a compatible input to be available. struct disable_inplace_value_error_exception_constructor; template - using choose_inplace_value_error_exception_constructor = std::conditional_t< // - ((static_cast(std::is_constructible::value) + static_cast(std::is_constructible::value) + static_cast(std::is_constructible::value)) > 1), // - disable_inplace_value_error_exception_constructor, // - std::conditional_t< // - std::is_constructible::value, // - value_type, // - std::conditional_t< // - std::is_constructible::value, // - error_type, // - std::conditional_t< // - std::is_constructible::value, // - exception_type, // + using choose_inplace_value_error_exception_constructor = std::conditional_t< // + ((static_cast(std::is_constructible::value) + static_cast(std::is_constructible::value) + + static_cast(std::is_constructible::value)) > 1), // + disable_inplace_value_error_exception_constructor, // + std::conditional_t< // + std::is_constructible::value, // + value_type, // + std::conditional_t< // + std::is_constructible::value, // + error_type, // + std::conditional_t< // + std::is_constructible::value, // + exception_type, // disable_inplace_value_error_exception_constructor>>>>; template static constexpr bool enable_inplace_value_error_exception_constructor = // - implicit_constructors_enabled && !std::is_same, disable_inplace_value_error_exception_constructor>::value; + implicit_constructors_enabled && + !std::is_same, disable_inplace_value_error_exception_constructor>::value; }; // Select whether to use basic_outcome_failure_observers or not template using select_basic_outcome_failure_observers = // - std::conditional_t::value && trait::is_exception_ptr_available

::value, basic_outcome_failure_observers, Base>; + std::conditional_t::value && trait::is_exception_ptr_available

::value, + basic_outcome_failure_observers, Base>; template constexpr inline const V &extract_exception_from_failure(const failure_type &v) { return v.exception(); } - template constexpr inline V &&extract_exception_from_failure(failure_type &&v) { return static_cast &&>(v).exception(); } + template constexpr inline V &&extract_exception_from_failure(failure_type &&v) + { + return static_cast &&>(v).exception(); + } template constexpr inline const U &extract_exception_from_failure(const failure_type &v) { return v.error(); } - template constexpr inline U &&extract_exception_from_failure(failure_type &&v) { return static_cast &&>(v).error(); } + template constexpr inline U &&extract_exception_from_failure(failure_type &&v) + { + return static_cast &&>(v).error(); + } template struct is_basic_outcome { @@ -181,36 +196,41 @@ SIGNATURE NOT RECOGNISED /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ - template constexpr inline void hook_outcome_in_place_construction(T * /*unused*/, in_place_type_t /*unused*/, Args &&... /*unused*/) noexcept {} + template + constexpr inline void hook_outcome_in_place_construction(T * /*unused*/, in_place_type_t /*unused*/, Args &&... /*unused*/) noexcept + { + } /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ - template constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept; + template + constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept; } // namespace hooks /*! AWAITING HUGO JSON CONVERSION TOOL type definition template basic_outcome. Potential doc page: `basic_outcome` */ -template // -BOOST_OUTCOME_REQUIRES(trait::type_can_be_used_in_basic_result

&& (std::is_void

::value || std::is_default_constructible

::value)) // +template // class BOOST_OUTCOME_NODISCARD basic_outcome #if defined(BOOST_OUTCOME_DOXYGEN_IS_IN_THE_HOUSE) || defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) : public detail::basic_outcome_failure_observers, R, S, P, NoValuePolicy>, public detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, public detail::basic_result_final #else - : public detail::select_basic_outcome_failure_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy> + : public detail::select_basic_outcome_failure_observers< + detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy> #endif { static_assert(trait::type_can_be_used_in_basic_result

, "The exception_type cannot be used"); static_assert(std::is_void

::value || std::is_default_constructible

::value, "exception_type must be void or default constructible"); - using base = detail::select_basic_outcome_failure_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy>; + using base = detail::select_basic_outcome_failure_observers< + detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy>; friend struct policy::base; - template // - BOOST_OUTCOME_REQUIRES(trait::type_can_be_used_in_basic_result && (std::is_void::value || std::is_default_constructible::value)) // + template // friend class basic_outcome; - template friend constexpr inline void hooks::override_outcome_exception(basic_outcome *o, X &&v) noexcept; // NOLINT + template + friend constexpr inline void hooks::override_outcome_exception(basic_outcome *o, X &&v) noexcept; // NOLINT struct implicit_constructors_disabled_tag { @@ -276,9 +296,12 @@ protected: using base = detail::outcome_predicates; // Predicate for any constructors to be available at all - static constexpr bool constructors_enabled = (!std::is_same, std::decay_t>::value || (std::is_void::value && std::is_void::value)) // - && (!std::is_same, std::decay_t>::value || (std::is_void::value && std::is_void::value)) // - && (!std::is_same, std::decay_t>::value || (std::is_void::value && std::is_void::value)) // + static constexpr bool constructors_enabled = + (!std::is_same, std::decay_t>::value || (std::is_void::value && std::is_void::value)) // + && (!std::is_same, std::decay_t>::value || + (std::is_void::value && std::is_void::value)) // + && (!std::is_same, std::decay_t>::value || + (std::is_void::value && std::is_void::value)) // ; // Predicate for implicit constructors to be available at all @@ -359,13 +382,17 @@ protected: static constexpr bool enable_inplace_value_error_exception_constructor = // constructors_enabled // &&base::template enable_inplace_value_error_exception_constructor; - template using choose_inplace_value_error_exception_constructor = typename base::template choose_inplace_value_error_exception_constructor; + template + using choose_inplace_value_error_exception_constructor = typename base::template choose_inplace_value_error_exception_constructor; }; public: - using value_type_if_enabled = std::conditional_t::value || std::is_same::value, disable_in_place_value_type, value_type>; - using error_type_if_enabled = std::conditional_t::value || std::is_same::value, disable_in_place_error_type, error_type>; - using exception_type_if_enabled = std::conditional_t::value || std::is_same::value, disable_in_place_exception_type, exception_type>; + using value_type_if_enabled = + std::conditional_t::value || std::is_same::value, disable_in_place_value_type, value_type>; + using error_type_if_enabled = + std::conditional_t::value || std::is_same::value, disable_in_place_error_type, error_type>; + using exception_type_if_enabled = std::conditional_t::value || std::is_same::value, + disable_in_place_exception_type, exception_type>; protected: detail::devoid _ptr; @@ -383,15 +410,18 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED((predicate::constructors_enabled && !predicate::implicit_constructors_enabled // - && (detail::is_implicitly_constructible || detail::is_implicitly_constructible || detail::is_implicitly_constructible) ))) - basic_outcome(T && /*unused*/, implicit_constructors_disabled_tag /*unused*/ = implicit_constructors_disabled_tag()) = delete; // NOLINT Implicit constructors disabled, use explicit in_place_type, success() or failure(). see docs! + && (detail::is_implicitly_constructible || detail::is_implicitly_constructible || + detail::is_implicitly_constructible) ))) + basic_outcome(T && /*unused*/, implicit_constructors_disabled_tag /*unused*/ = implicit_constructors_disabled_tag()) = + delete; // NOLINT Implicit constructors disabled, use explicit in_place_type, success() or failure(). see docs! /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_value_converting_constructor)) - constexpr basic_outcome(T &&t, value_converting_constructor_tag /*unused*/ = value_converting_constructor_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(T &&t, value_converting_constructor_tag /*unused*/ = value_converting_constructor_tag()) noexcept( + std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, static_cast(t)} , _ptr() { @@ -403,7 +433,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_converting_constructor)) - constexpr basic_outcome(T &&t, error_converting_constructor_tag /*unused*/ = error_converting_constructor_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(T &&t, error_converting_constructor_tag /*unused*/ = error_converting_constructor_tag()) noexcept( + std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, static_cast(t)} , _ptr() { @@ -416,7 +447,8 @@ SIGNATURE NOT RECOGNISED BOOST_OUTCOME_TEMPLATE(class ErrorCondEnum) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(error_type(make_error_code(ErrorCondEnum()))), // BOOST_OUTCOME_TPRED(predicate::template enable_error_condition_converting_constructor)) - constexpr basic_outcome(ErrorCondEnum &&t, error_condition_converting_constructor_tag /*unused*/ = error_condition_converting_constructor_tag()) noexcept(noexcept(error_type(make_error_code(static_cast(t))))) // NOLINT + constexpr basic_outcome(ErrorCondEnum &&t, error_condition_converting_constructor_tag /*unused*/ = error_condition_converting_constructor_tag()) noexcept( + noexcept(error_type(make_error_code(static_cast(t))))) // NOLINT : base{in_place_type, make_error_code(t)} { using namespace hooks; @@ -427,12 +459,13 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_exception_converting_constructor)) - constexpr basic_outcome(T &&t, exception_converting_constructor_tag /*unused*/ = exception_converting_constructor_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(T &&t, exception_converting_constructor_tag /*unused*/ = exception_converting_constructor_tag()) noexcept( + std::is_nothrow_constructible::value) // NOLINT : base() , _ptr(static_cast(t)) { using namespace hooks; - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); hook_outcome_construction(this, static_cast(t)); } /*! AWAITING HUGO JSON CONVERSION TOOL @@ -440,12 +473,13 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_exception_converting_constructor)) - constexpr basic_outcome(T &&a, U &&b, error_exception_converting_constructor_tag /*unused*/ = error_exception_converting_constructor_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(T &&a, U &&b, error_exception_converting_constructor_tag /*unused*/ = error_exception_converting_constructor_tag()) noexcept( + std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, static_cast(a)} , _ptr(static_cast(b)) { using namespace hooks; - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); hook_outcome_construction(this, static_cast(a), static_cast(b)); } @@ -456,7 +490,8 @@ SIGNATURE NOT RECOGNISED BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(convert::value_or_error>::enable_result_inputs || !is_basic_result_v), // BOOST_OUTCOME_TPRED(convert::value_or_error>::enable_outcome_inputs || !is_basic_outcome_v), // BOOST_OUTCOME_TEXPR(convert::value_or_error>{}(std::declval()))) - constexpr explicit basic_outcome(T &&o, explicit_valueorerror_converting_constructor_tag /*unused*/ = explicit_valueorerror_converting_constructor_tag()) // NOLINT + constexpr explicit basic_outcome(T &&o, + explicit_valueorerror_converting_constructor_tag /*unused*/ = explicit_valueorerror_converting_constructor_tag()) // NOLINT : basic_outcome{convert::value_or_error>{}(static_cast(o))} { } @@ -465,8 +500,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion)) - constexpr explicit basic_outcome(const basic_outcome &o, - explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) + constexpr explicit basic_outcome( + const basic_outcome &o, + explicit_compatible_copy_conversion_tag /*unused*/ = + explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value + &&std::is_nothrow_constructible::value) : base{typename base::compatible_conversion_tag(), o} , _ptr(o._ptr) { @@ -478,8 +516,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion)) - constexpr explicit basic_outcome(basic_outcome &&o, - explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) + constexpr explicit basic_outcome( + basic_outcome &&o, + explicit_compatible_move_conversion_tag /*unused*/ = + explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value + &&std::is_nothrow_constructible::value) : base{typename base::compatible_conversion_tag(), static_cast &&>(o)} , _ptr(static_cast::exception_type &&>(o._ptr)) { @@ -491,8 +532,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_compatible_conversion)) - constexpr explicit basic_outcome(const basic_result &o, - explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) + constexpr explicit basic_outcome( + const basic_result &o, + explicit_compatible_copy_conversion_tag /*unused*/ = + explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value + &&std::is_nothrow_constructible::value) : base{typename base::compatible_conversion_tag(), o} , _ptr() { @@ -504,8 +548,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_compatible_conversion)) - constexpr explicit basic_outcome(basic_result &&o, - explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) + constexpr explicit basic_outcome( + basic_result &&o, + explicit_compatible_move_conversion_tag /*unused*/ = + explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value + &&std::is_nothrow_constructible::value) : base{typename base::compatible_conversion_tag(), static_cast &&>(o)} , _ptr() { @@ -517,8 +564,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_make_error_code_compatible_conversion)) - constexpr explicit basic_outcome(const basic_result &o, explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&noexcept(make_error_code(std::declval())) && - std::is_nothrow_constructible::value) + constexpr explicit basic_outcome(const basic_result &o, + explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = + explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value + &&noexcept(make_error_code(std::declval())) && + std::is_nothrow_constructible::value) : base{typename base::make_error_code_compatible_conversion_tag(), o} , _ptr() { @@ -530,8 +580,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U, class V) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_make_error_code_compatible_conversion)) - constexpr explicit basic_outcome(basic_result &&o, explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = explicit_make_error_code_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&noexcept(make_error_code(std::declval())) && - std::is_nothrow_constructible::value) + constexpr explicit basic_outcome(basic_result &&o, + explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = + explicit_make_error_code_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value + &&noexcept(make_error_code(std::declval())) && + std::is_nothrow_constructible::value) : base{typename base::make_error_code_compatible_conversion_tag(), static_cast &&>(o)} , _ptr() { @@ -545,7 +598,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor)) - constexpr explicit basic_outcome(in_place_type_t _, Args &&... args) noexcept(std::is_nothrow_constructible::value) + constexpr explicit basic_outcome(in_place_type_t _, + Args &&... args) noexcept(std::is_nothrow_constructible::value) : base{_, static_cast(args)...} , _ptr() { @@ -557,7 +611,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class U, class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) + constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, + Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) : base{_, il, static_cast(args)...} , _ptr() { @@ -569,7 +624,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor)) - constexpr explicit basic_outcome(in_place_type_t _, Args &&... args) noexcept(std::is_nothrow_constructible::value) + constexpr explicit basic_outcome(in_place_type_t _, + Args &&... args) noexcept(std::is_nothrow_constructible::value) : base{_, static_cast(args)...} , _ptr() { @@ -581,7 +637,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class U, class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) + constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, + Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) : base{_, il, static_cast(args)...} , _ptr() { @@ -593,12 +650,13 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor)) - constexpr explicit basic_outcome(in_place_type_t /*unused*/, Args &&... args) noexcept(std::is_nothrow_constructible::value) + constexpr explicit basic_outcome(in_place_type_t /*unused*/, + Args &&... args) noexcept(std::is_nothrow_constructible::value) : base() , _ptr(static_cast(args)...) { using namespace hooks; - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); hook_outcome_in_place_construction(this, in_place_type, static_cast(args)...); } /*! AWAITING HUGO JSON CONVERSION TOOL @@ -606,12 +664,13 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class U, class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t /*unused*/, std::initializer_list il, Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) + constexpr explicit basic_outcome(in_place_type_t /*unused*/, std::initializer_list il, + Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) : base() , _ptr(il, static_cast(args)...) { using namespace hooks; - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); hook_outcome_in_place_construction(this, in_place_type, il, static_cast(args)...); } /*! AWAITING HUGO JSON CONVERSION TOOL @@ -619,8 +678,11 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class A1, class A2, class... Args) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_error_exception_constructor)) - constexpr basic_outcome(A1 &&a1, A2 &&a2, Args &&... args) noexcept(noexcept(typename predicate::template choose_inplace_value_error_exception_constructor(std::declval(), std::declval(), std::declval()...))) - : basic_outcome(in_place_type>, static_cast(a1), static_cast(a2), static_cast(args)...) + constexpr basic_outcome(A1 &&a1, A2 &&a2, Args &&... args) noexcept( + noexcept(typename predicate::template choose_inplace_value_error_exception_constructor(std::declval(), std::declval(), + std::declval()...))) + : basic_outcome(in_place_type>, static_cast(a1), + static_cast(a2), static_cast(args)...) { } @@ -661,7 +723,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(const failure_type &o, + error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, detail::extract_error_from_failure(o)} , _ptr() { @@ -673,11 +736,12 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(const failure_type &o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept( + std::is_nothrow_constructible::value) // NOLINT : base() , _ptr(detail::extract_exception_from_failure(o)) { - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); using namespace hooks; hook_outcome_copy_construction(this, o); } @@ -686,7 +750,9 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_make_error_code_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT + constexpr basic_outcome(const failure_type &o, + explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = + explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT : base{in_place_type, make_error_code(detail::extract_error_from_failure(o))} , _ptr() { @@ -698,17 +764,18 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(const failure_type &o, explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept( + std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, detail::extract_error_from_failure(o)} , _ptr(detail::extract_exception_from_failure(o)) { if(!o.has_error()) { - this->_state._status &= ~detail::status_have_error; + this->_state._status.set_have_error(false); } if(o.has_exception()) { - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); } using namespace hooks; hook_outcome_copy_construction(this, o); @@ -719,7 +786,8 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(failure_type &&o, + error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, detail::extract_error_from_failure(static_cast &&>(o))} , _ptr() { @@ -731,11 +799,12 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(failure_type &&o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept( + std::is_nothrow_constructible::value) // NOLINT : base() , _ptr(detail::extract_exception_from_failure(static_cast &&>(o))) { - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); using namespace hooks; hook_outcome_copy_construction(this, o); } @@ -744,7 +813,9 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_make_error_code_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = explicit_make_error_code_compatible_move_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT + constexpr basic_outcome(failure_type &&o, + explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = + explicit_make_error_code_compatible_move_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT : base{in_place_type, make_error_code(detail::extract_error_from_failure(static_cast &&>(o)))} , _ptr() { @@ -756,17 +827,18 @@ SIGNATURE NOT RECOGNISED */ BOOST_OUTCOME_TEMPLATE(class T, class U) BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT + constexpr basic_outcome(failure_type &&o, explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept( + std::is_nothrow_constructible::value &&std::is_nothrow_constructible::value) // NOLINT : base{in_place_type, detail::extract_error_from_failure(static_cast &&>(o))} , _ptr(detail::extract_exception_from_failure(static_cast &&>(o))) { if(!o.has_error()) { - this->_state._status &= ~detail::status_have_error; + this->_state._status.set_have_error(false); } if(o.has_exception()) { - this->_state._status |= detail::status_have_exception; + this->_state._status.set_have_exception(true); } using namespace hooks; hook_outcome_move_construction(this, static_cast &&>(o)); @@ -789,20 +861,20 @@ SIGNATURE NOT RECOGNISED && noexcept(std::declval>() == std::declval>()) // && noexcept(std::declval>() == std::declval>())) { - if((this->_state._status & detail::status_have_value) != 0 && (o._state._status & detail::status_have_value) != 0) + if(this->_state._status.have_value() && o._state._status.have_value()) { return this->_state._value == o._state._value; // NOLINT } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0 // - && (this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_error() && o._state._status.have_error() // + && this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_error == o._error && this->_ptr == o._ptr; } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0) + if(this->_state._status.have_error() && o._state._status.have_error()) { return this->_error == o._error; } - if((this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_ptr == o._ptr; } @@ -817,16 +889,16 @@ SIGNATURE NOT RECOGNISED constexpr bool operator==(const failure_type &o) const noexcept( // noexcept(std::declval() == std::declval()) && noexcept(std::declval() == std::declval())) { - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0 // - && (this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_error() && o._state._status.have_error() // + && this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_error == o.error() && this->_ptr == o.exception(); } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0) + if(this->_state._status.have_error() && o._state._status.have_error()) { return this->_error == o.error(); } - if((this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_ptr == o.exception(); } @@ -844,20 +916,20 @@ SIGNATURE NOT RECOGNISED && noexcept(std::declval>() != std::declval>()) // && noexcept(std::declval>() != std::declval>())) { - if((this->_state._status & detail::status_have_value) != 0 && (o._state._status & detail::status_have_value) != 0) + if(this->_state._status.have_value() && o._state._status.have_value()) { return this->_state._value != o._state._value; // NOLINT } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0 // - && (this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_error() && o._state._status.have_error() // + && this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_error != o._error || this->_ptr != o._ptr; } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0) + if(this->_state._status.have_error() && o._state._status.have_error()) { return this->_error != o._error; } - if((this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_ptr != o._ptr; } @@ -872,16 +944,16 @@ SIGNATURE NOT RECOGNISED constexpr bool operator!=(const failure_type &o) const noexcept( // noexcept(std::declval() == std::declval()) && noexcept(std::declval() == std::declval())) { - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0 // - && (this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_error() && o._state._status.have_error() // + && this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_error != o.error() || this->_ptr != o.exception(); } - if((this->_state._status & detail::status_have_error) != 0 && (o._state._status & detail::status_have_error) != 0) + if(this->_state._status.have_error() && o._state._status.have_error()) { return this->_error != o.error(); } - if((this->_state._status & detail::status_have_exception) != 0 && (o._state._status & detail::status_have_exception) != 0) + if(this->_state._status.have_exception() && o._state._status.have_exception()) { return this->_ptr != o.exception(); } @@ -921,8 +993,8 @@ SIGNATURE NOT RECOGNISED if(!all_good) { // We lost one of the values - a._state._status |= detail::status_lost_consistency; - b._state._status |= detail::status_lost_consistency; + a._state._status.set_have_lost_consistency(true); + b._state._status.set_have_lost_consistency(true); return; } if(exceptioned) @@ -935,8 +1007,8 @@ SIGNATURE NOT RECOGNISED catch(...) { // We lost one of the values - a._state._status |= detail::status_lost_consistency; - b._state._status |= detail::status_lost_consistency; + a._state._status.set_have_lost_consistency(true); + b._state._status.set_have_lost_consistency(true); // throw away second exception } @@ -944,13 +1016,13 @@ SIGNATURE NOT RECOGNISED auto check = [](basic_outcome *t) { if(t->has_value() && (t->has_error() || t->has_exception())) { - t->_state._status &= ~(detail::status_have_error | detail::status_have_exception); - t->_state._status |= detail::status_lost_consistency; + t->_state._status.set_have_error(false).set_have_exception(false); + t->_state._status.set_have_lost_consistency(true); } if(!t->has_value() && !(t->has_error() || t->has_exception())) { // Choose error, for no particular reason - t->_state._status |= detail::status_have_error | detail::status_lost_consistency; + t->_state._status.set_have_error(true).set_have_lost_consistency(true); } }; check(&a); @@ -1040,10 +1112,11 @@ namespace hooks /*! AWAITING HUGO JSON CONVERSION TOOL SIGNATURE NOT RECOGNISED */ - template constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept + template + constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept { o->_ptr = static_cast(v); // NOLINT - o->_state._status |= detail::status_have_exception; + o->_state._status.set_have_exception(true); } } // namespace hooks @@ -1059,12 +1132,16 @@ BOOST_OUTCOME_V2_NAMESPACE_END BOOST_OUTCOME_V2_NAMESPACE_BEGIN // Check is trivial in all ways except default constructibility and standard layout // static_assert(std::is_trivial>::value, "outcome is not trivial!"); -// static_assert(std::is_trivially_default_constructible>::value, "outcome is not trivially default constructible!"); +// static_assert(std::is_trivially_default_constructible>::value, "outcome is not trivially default +// constructible!"); static_assert(std::is_trivially_copyable>::value, "outcome is not trivially copyable!"); -static_assert(std::is_trivially_assignable, basic_outcome>::value, "outcome is not trivially assignable!"); +static_assert(std::is_trivially_assignable, basic_outcome>::value, + "outcome is not trivially assignable!"); static_assert(std::is_trivially_destructible>::value, "outcome is not trivially destructible!"); -static_assert(std::is_trivially_copy_constructible>::value, "outcome is not trivially copy constructible!"); -static_assert(std::is_trivially_move_constructible>::value, "outcome is not trivially move constructible!"); +static_assert(std::is_trivially_copy_constructible>::value, + "outcome is not trivially copy constructible!"); +static_assert(std::is_trivially_move_constructible>::value, + "outcome is not trivially move constructible!"); static_assert(std::is_trivially_copy_assignable>::value, "outcome is not trivially copy assignable!"); static_assert(std::is_trivially_move_assignable>::value, "outcome is not trivially move assignable!"); // Can't be standard layout as non-static member data is defined in more than one inherited class