Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:59:13

0001 /* A very simple result type
0002 (C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (14 commits)
0003 File Created: June 2017
0004 
0005 
0006 Boost Software License - Version 1.0 - August 17th, 2003
0007 
0008 Permission is hereby granted, free of charge, to any person or organization
0009 obtaining a copy of the software and accompanying documentation covered by
0010 this license (the "Software") to use, reproduce, display, distribute,
0011 execute, and transmit the Software, and to prepare derivative works of the
0012 Software, and to permit third-parties to whom the Software is furnished to
0013 do so, all subject to the following:
0014 
0015 The copyright notices in the Software and this entire statement, including
0016 the above license grant, this restriction and the following disclaimer,
0017 must be included in all copies of the Software, in whole or in part, and
0018 all derivative works of the Software, unless such copies or derivative
0019 works are solely in the form of machine-executable object code generated by
0020 a source language processor.
0021 
0022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0024 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
0025 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
0026 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
0027 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0028 DEALINGS IN THE SOFTWARE.
0029 */
0030 
0031 #ifndef BOOST_OUTCOME_BASIC_RESULT_HPP
0032 #define BOOST_OUTCOME_BASIC_RESULT_HPP
0033 
0034 #include "config.hpp"
0035 #include "convert.hpp"
0036 #include "detail/basic_result_final.hpp"
0037 #include "outcome_gdb.h"
0038 
0039 #include "policy/all_narrow.hpp"
0040 #include "policy/terminate.hpp"
0041 
0042 #ifdef __clang__
0043 #pragma clang diagnostic push
0044 #pragma clang diagnostic ignored "-Wdocumentation"  // Standardese markup confuses clang
0045 #endif
0046 
0047 #if defined(_MSC_VER) && !defined(__clang__)
0048 #pragma warning(push)
0049 #pragma warning(disable: 6287) // redundant code
0050 #endif
0051 
0052 BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN
0053 
0054 template <class R, class S, class NoValuePolicy>  //
0055 class basic_result;
0056 
0057 namespace detail
0058 {
0059   // These are reused by basic_outcome to save load on the compiler
0060   template <class value_type, class error_type> struct result_predicates
0061   {
0062     // Predicate for the implicit constructors to be available. Weakened to allow result<int, C enum>.
0063     static constexpr bool implicit_constructors_enabled =  //
0064     !(trait::is_error_type<std::decay_t<value_type>>::value &&
0065       trait::is_error_type<std::decay_t<error_type>>::value)  // both value and error types are not whitelisted error types
0066     && ((!detail::is_implicitly_constructible<value_type, error_type> &&
0067          !detail::is_implicitly_constructible<error_type, value_type>)       // if value and error types cannot be constructed into one another
0068         || (trait::is_error_type<std::decay_t<error_type>>::value            // if error type is a whitelisted error type
0069             && !detail::is_implicitly_constructible<error_type, value_type>  // AND which cannot be constructed from the value type
0070             && std::is_integral<value_type>::value));                        // AND the value type is some integral type
0071 
0072     // Predicate for the value converting constructor to be available. Weakened to allow result<int, C enum>.
0073     template <class T>
0074     static constexpr bool enable_value_converting_constructor =                                                      //
0075     implicit_constructors_enabled                                                                                    //
0076     && !is_in_place_type_t<std::decay_t<T>>::value                                                                   // not in place construction
0077     && !trait::is_error_type_enum<error_type, std::decay_t<T>>::value                                                // not an enum valid for my error type
0078     && ((detail::is_implicitly_constructible<value_type, T> && !detail::is_implicitly_constructible<error_type, T>)  // is unambiguously for value type
0079         || (std::is_same<value_type, std::decay_t<T>>::value                                                         // OR is my value type exactly
0080             && detail::is_implicitly_constructible<value_type, T>) );  // and my value type is constructible from this ref form of T
0081 
0082 
0083     // Predicate for the error converting constructor to be available. Weakened to allow result<int, C enum>.
0084     template <class T>
0085     static constexpr bool enable_error_converting_constructor =                                                      //
0086     implicit_constructors_enabled                                                                                    //
0087     && !is_in_place_type_t<std::decay_t<T>>::value                                                                   // not in place construction
0088     && !trait::is_error_type_enum<error_type, std::decay_t<T>>::value                                                // not an enum valid for my error type
0089     && ((!detail::is_implicitly_constructible<value_type, T> && detail::is_implicitly_constructible<error_type, T>)  // is unambiguously for error type
0090         || (std::is_same<error_type, std::decay_t<T>>::value                                                         // OR is my error type exactly
0091             && detail::is_implicitly_constructible<error_type, T>) );  // and my error type is constructible from this ref form of T
0092 
0093     // Predicate for the error condition converting constructor to be available.
0094     template <class ErrorCondEnum>
0095     static constexpr bool enable_error_condition_converting_constructor =         //
0096     !is_in_place_type_t<std::decay_t<ErrorCondEnum>>::value                       // not in place construction
0097     && trait::is_error_type_enum<error_type, std::decay_t<ErrorCondEnum>>::value  // is an error condition enum
0098     /*&& !detail::is_implicitly_constructible<value_type, ErrorCondEnum> && !detail::is_implicitly_constructible<error_type, ErrorCondEnum>*/;  // not
0099                                                                                                                                                 // constructible
0100                                                                                                                                                 // via any other
0101                                                                                                                                                 // means
0102 
0103     // Predicate for the converting constructor from a compatible input to be available.
0104     template <class T, class U, class V>
0105     static constexpr bool enable_compatible_conversion =  //
0106     (std::is_void<T>::value ||
0107      detail::is_explicitly_constructible<value_type, typename basic_result<T, U, V>::value_type>)  // if our value types are constructible
0108     &&(std::is_void<U>::value ||
0109        detail::is_explicitly_constructible<error_type, typename basic_result<T, U, V>::error_type>)  // if our error types are constructible
0110     ;
0111 
0112     // Predicate for the converting constructor from a make_error_code() of the input to be available.
0113     template <class T, class U, class V>
0114     static constexpr bool enable_make_error_code_compatible_conversion =  //
0115     trait::is_error_code_available<std::decay_t<error_type>>::value       // if error type has an error code
0116     && !enable_compatible_conversion<T, U, V>                             // and the normal compatible conversion is not available
0117     && (std::is_void<T>::value ||
0118         detail::is_explicitly_constructible<value_type, typename basic_result<T, U, V>::value_type>)  // and if our value types are constructible
0119     &&detail::is_explicitly_constructible<error_type,
0120                                           typename trait::is_error_code_available<U>::type>;  // and our error type is constructible from a make_error_code()
0121 
0122     // Predicate for the converting constructor from a make_exception_ptr() of the input to be available.
0123     template <class T, class U, class V>
0124     static constexpr bool enable_make_exception_ptr_compatible_conversion =  //
0125     trait::is_exception_ptr_available<std::decay_t<error_type>>::value       // if error type has an exception ptr
0126     && !enable_compatible_conversion<T, U, V>                                // and the normal compatible conversion is not available
0127     && (std::is_void<T>::value ||
0128         detail::is_explicitly_constructible<value_type, typename basic_result<T, U, V>::value_type>)         // and if our value types are constructible
0129     &&detail::is_explicitly_constructible<error_type, typename trait::is_exception_ptr_available<U>::type>;  // and our error type is constructible from a
0130                                                                                                              // make_exception_ptr()
0131 
0132     // Predicate for the implicit converting inplace constructor from a compatible input to be available.
0133     struct disable_inplace_value_error_constructor;
0134     template <class... Args>
0135     using choose_inplace_value_error_constructor = std::conditional_t<                               //
0136     detail::is_constructible<value_type, Args...> && detail::is_constructible<error_type, Args...>,  //
0137     disable_inplace_value_error_constructor,                                                         //
0138     std::conditional_t<                                                                              //
0139     detail::is_constructible<value_type, Args...>,                                                   //
0140     value_type,                                                                                      //
0141     std::conditional_t<                                                                              //
0142     detail::is_constructible<error_type, Args...>,                                                   //
0143     error_type,                                                                                      //
0144     disable_inplace_value_error_constructor>>>;
0145     template <class... Args>
0146     static constexpr bool enable_inplace_value_error_constructor =
0147     implicit_constructors_enabled  //
0148     && !std::is_same<choose_inplace_value_error_constructor<Args...>, disable_inplace_value_error_constructor>::value;
0149   };
0150 
0151   template <class T, class U> constexpr inline const U &extract_value_from_success(const success_type<U> &v)
0152   {
0153     return v.value();
0154   }
0155   template <class T, class U> constexpr inline U &&extract_value_from_success(success_type<U> &&v)
0156   {
0157     return static_cast<success_type<U> &&>(v).value();
0158   }
0159   template <class T> constexpr inline T extract_value_from_success(const success_type<void> & /*unused*/)
0160   {
0161     return T{};
0162   }
0163 
0164   template <class T, class U, class V> constexpr inline const U &extract_error_from_failure(const failure_type<U, V> &v)
0165   {
0166     return v.error();
0167   }
0168   template <class T, class U, class V> constexpr inline U &&extract_error_from_failure(failure_type<U, V> &&v)
0169   {
0170     return static_cast<failure_type<U, V> &&>(v).error();
0171   }
0172   template <class T, class V> constexpr inline T extract_error_from_failure(const failure_type<void, V> & /*unused*/)
0173   {
0174     return T{};
0175   }
0176 
0177   template <class T> struct is_basic_result
0178   {
0179     static constexpr bool value = false;
0180   };
0181   template <class R, class S, class T> struct is_basic_result<basic_result<R, S, T>>
0182   {
0183     static constexpr bool value = true;
0184   };
0185 }  // namespace detail
0186 
0187 /*! AWAITING HUGO JSON CONVERSION TOOL
0188 type alias template <class T> is_basic_result. Potential doc page: `is_basic_result<T>`
0189 */
0190 template <class T> using is_basic_result = detail::is_basic_result<std::decay_t<T>>;
0191 /*! AWAITING HUGO JSON CONVERSION TOOL
0192 SIGNATURE NOT RECOGNISED
0193 */
0194 template <class T> static constexpr bool is_basic_result_v = detail::is_basic_result<std::decay_t<T>>::value;
0195 
0196 namespace concepts
0197 {
0198 #if defined(__cpp_concepts)
0199   /* The `basic_result` concept.
0200   \requires That `U` matches a `basic_result`.
0201   */
0202   template <class U>
0203   concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL basic_result =
0204   BOOST_OUTCOME_V2_NAMESPACE::is_basic_result<U>::value ||
0205   (requires(U v) { BOOST_OUTCOME_V2_NAMESPACE::basic_result<typename U::value_type, typename U::error_type, typename U::no_value_policy_type>(v); } &&    //
0206    detail::convertible<U, BOOST_OUTCOME_V2_NAMESPACE::basic_result<typename U::value_type, typename U::error_type, typename U::no_value_policy_type>> &&  //
0207    detail::base_of<BOOST_OUTCOME_V2_NAMESPACE::basic_result<typename U::value_type, typename U::error_type, typename U::no_value_policy_type>, U>);
0208 #else
0209   namespace detail
0210   {
0211     inline no_match match_basic_result(...);
0212     template <class R, class S, class NVP, class T,                                                                      //
0213               typename = typename T::value_type,                                                                         //
0214               typename = typename T::error_type,                                                                         //
0215               typename = typename T::no_value_policy_type,                                                               //
0216               typename std::enable_if_t<std::is_convertible<T, BOOST_OUTCOME_V2_NAMESPACE::basic_result<R, S, NVP>>::value &&  //
0217                                         std::is_base_of<BOOST_OUTCOME_V2_NAMESPACE::basic_result<R, S, NVP>, T>::value,
0218                                         bool> = true>
0219     inline BOOST_OUTCOME_V2_NAMESPACE::basic_result<R, S, NVP> match_basic_result(BOOST_OUTCOME_V2_NAMESPACE::basic_result<R, S, NVP> &&, T &&);
0220 
0221     template <class U>
0222     static constexpr bool basic_result = BOOST_OUTCOME_V2_NAMESPACE::is_basic_result<U>::value ||
0223                                          !std::is_same<no_match, decltype(match_basic_result(std::declval<BOOST_OUTCOME_V2_NAMESPACE::detail::devoid<U>>(),
0224                                                                                              std::declval<BOOST_OUTCOME_V2_NAMESPACE::detail::devoid<U>>()))>::value;
0225   }  // namespace detail
0226   /* The `basic_result` concept.
0227   \requires That `U` matches a `basic_result`.
0228   */
0229   template <class U> static constexpr bool basic_result = detail::basic_result<U>;
0230 #endif
0231 }  // namespace concepts
0232 
0233 /*! AWAITING HUGO JSON CONVERSION TOOL
0234 SIGNATURE NOT RECOGNISED
0235 */
0236 namespace hooks
0237 {
0238   /*! AWAITING HUGO JSON CONVERSION TOOL
0239 SIGNATURE NOT RECOGNISED
0240 */
0241   template <class R, class S, class NoValuePolicy> constexpr inline uint16_t spare_storage(const detail::basic_result_storage<R, S, NoValuePolicy> *r) noexcept
0242   {
0243     return r->_state._status.spare_storage_value;
0244   }
0245   /*! AWAITING HUGO JSON CONVERSION TOOL
0246 SIGNATURE NOT RECOGNISED
0247 */
0248   template <class R, class S, class NoValuePolicy>
0249   constexpr inline void set_spare_storage(detail::basic_result_storage<R, S, NoValuePolicy> *r, uint16_t v) noexcept
0250   {
0251     r->_state._status.spare_storage_value = v;
0252   }
0253 }  // namespace hooks
0254 
0255 /*! AWAITING HUGO JSON CONVERSION TOOL
0256 type definition template <class R, class S, class NoValuePolicy> basic_result. Potential doc page: `basic_result<T, E, NoValuePolicy>`
0257 */
0258 template <class R, class S, class NoValuePolicy>  //
0259 class BOOST_OUTCOME_NODISCARD basic_result : public detail::basic_result_final<R, S, NoValuePolicy>
0260 {
0261   static_assert(trait::type_can_be_used_in_basic_result<R>, "The type R cannot be used in a basic_result");
0262   static_assert(trait::type_can_be_used_in_basic_result<S>, "The type S cannot be used in a basic_result");
0263 
0264   using base = detail::basic_result_final<R, S, NoValuePolicy>;
0265 
0266   struct implicit_constructors_disabled_tag
0267   {
0268   };
0269   struct value_converting_constructor_tag
0270   {
0271   };
0272   struct error_converting_constructor_tag
0273   {
0274   };
0275   struct error_condition_converting_constructor_tag
0276   {
0277   };
0278   struct explicit_valueornone_converting_constructor_tag
0279   {
0280   };
0281   struct explicit_valueorerror_converting_constructor_tag
0282   {
0283   };
0284   struct explicit_compatible_copy_conversion_tag
0285   {
0286   };
0287   struct explicit_compatible_move_conversion_tag
0288   {
0289   };
0290   struct explicit_make_error_code_compatible_copy_conversion_tag
0291   {
0292   };
0293   struct explicit_make_error_code_compatible_move_conversion_tag
0294   {
0295   };
0296   struct explicit_make_exception_ptr_compatible_copy_conversion_tag
0297   {
0298   };
0299   struct explicit_make_exception_ptr_compatible_move_conversion_tag
0300   {
0301   };
0302 
0303 public:
0304   using value_type = R;
0305   using error_type = S;
0306   using no_value_policy_type = NoValuePolicy;
0307 
0308   using value_type_if_enabled = typename base::_value_type;
0309   using error_type_if_enabled = typename base::_error_type;
0310 
0311   template <class T, class U = S, class V = NoValuePolicy> using rebind = basic_result<T, U, V>;
0312 
0313 protected:
0314   // Requirement predicates for result.
0315   struct predicate
0316   {
0317     using base = detail::result_predicates<value_type, error_type>;
0318 
0319     // Predicate for any constructors to be available at all
0320     static constexpr bool constructors_enabled = !std::is_same<std::decay_t<value_type>, std::decay_t<error_type>>::value;
0321 
0322     // Predicate for implicit constructors to be available at all
0323     static constexpr bool implicit_constructors_enabled = constructors_enabled && base::implicit_constructors_enabled;
0324 
0325     // Predicate for the value converting constructor to be available.
0326     template <class T>
0327     static constexpr bool enable_value_converting_constructor =  //
0328     constructors_enabled                                         //
0329     && !std::is_same<std::decay_t<T>, basic_result>::value       // not my type
0330     && base::template enable_value_converting_constructor<T>;
0331 
0332     // Predicate for the error converting constructor to be available.
0333     template <class T>
0334     static constexpr bool enable_error_converting_constructor =  //
0335     constructors_enabled                                         //
0336     && !std::is_same<std::decay_t<T>, basic_result>::value       // not my type
0337     && base::template enable_error_converting_constructor<T>;
0338 
0339     // Predicate for the error condition converting constructor to be available.
0340     template <class ErrorCondEnum>
0341     static constexpr bool enable_error_condition_converting_constructor =  //
0342     constructors_enabled                                                   //
0343     && !std::is_same<std::decay_t<ErrorCondEnum>, basic_result>::value     // not my type
0344     && base::template enable_error_condition_converting_constructor<ErrorCondEnum>;
0345 
0346     // Predicate for the converting constructor from a compatible input to be available.
0347     template <class T, class U, class V>
0348     static constexpr bool enable_compatible_conversion =          //
0349     constructors_enabled                                          //
0350     && !std::is_same<basic_result<T, U, V>, basic_result>::value  // not my type
0351     && base::template enable_compatible_conversion<T, U, V>;
0352 
0353     // Predicate for the converting constructor from a make_error_code() of the input to be available.
0354     template <class T, class U, class V>
0355     static constexpr bool enable_make_error_code_compatible_conversion =  //
0356     constructors_enabled                                                  //
0357     && !std::is_same<basic_result<T, U, V>, basic_result>::value          // not my type
0358     && base::template enable_make_error_code_compatible_conversion<T, U, V>;
0359 
0360     // Predicate for the converting constructor from a make_exception_ptr() of the input to be available.
0361     template <class T, class U, class V>
0362     static constexpr bool enable_make_exception_ptr_compatible_conversion =  //
0363     constructors_enabled                                                     //
0364     && !std::is_same<basic_result<T, U, V>, basic_result>::value             // not my type
0365     && base::template enable_make_exception_ptr_compatible_conversion<T, U, V>;
0366 
0367     // Predicate for the inplace construction of value to be available.
0368     template <class... Args>
0369     static constexpr bool enable_inplace_value_constructor =  //
0370     constructors_enabled                                      //
0371     && (std::is_void<value_type>::value                       //
0372         || detail::is_constructible<value_type, Args...>);
0373 
0374     // Predicate for the inplace construction of error to be available.
0375     template <class... Args>
0376     static constexpr bool enable_inplace_error_constructor =  //
0377     constructors_enabled                                      //
0378     && (std::is_void<error_type>::value                       //
0379         || detail::is_constructible<error_type, Args...>);
0380 
0381     // Predicate for the implicit converting inplace constructor to be available.
0382     template <class... Args>
0383     static constexpr bool enable_inplace_value_error_constructor =  //
0384     constructors_enabled                                            //
0385     && base::template enable_inplace_value_error_constructor<Args...>;
0386     template <class... Args> using choose_inplace_value_error_constructor = typename base::template choose_inplace_value_error_constructor<Args...>;
0387   };
0388 
0389 public:
0390   /*! AWAITING HUGO JSON CONVERSION TOOL
0391 SIGNATURE NOT RECOGNISED
0392 */
0393   basic_result() = delete;
0394   /*! AWAITING HUGO JSON CONVERSION TOOL
0395 SIGNATURE NOT RECOGNISED
0396 */
0397   basic_result(basic_result && /*unused*/) = default;  // NOLINT
0398   /*! AWAITING HUGO JSON CONVERSION TOOL
0399 SIGNATURE NOT RECOGNISED
0400 */
0401   basic_result(const basic_result & /*unused*/) = default;
0402   /*! AWAITING HUGO JSON CONVERSION TOOL
0403 SIGNATURE NOT RECOGNISED
0404 */
0405   basic_result &operator=(basic_result && /*unused*/) = default;  // NOLINT
0406   /*! AWAITING HUGO JSON CONVERSION TOOL
0407 SIGNATURE NOT RECOGNISED
0408 */
0409   basic_result &operator=(const basic_result & /*unused*/) = default;
0410   ~basic_result() = default;
0411 
0412   /*! AWAITING HUGO JSON CONVERSION TOOL
0413 SIGNATURE NOT RECOGNISED
0414 */
0415   BOOST_OUTCOME_TEMPLATE(class Arg, class... Args)
0416   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!predicate::constructors_enabled && (sizeof...(Args) >= 0)))
0417   basic_result(Arg && /*unused*/, Args &&.../*unused*/) = delete;  // NOLINT basic_result<T, T> is NOT SUPPORTED, see docs!
0418 
0419   /*! AWAITING HUGO JSON CONVERSION TOOL
0420 SIGNATURE NOT RECOGNISED
0421 */
0422   BOOST_OUTCOME_TEMPLATE(class T)
0423   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED((predicate::constructors_enabled && !predicate::implicit_constructors_enabled  //
0424                                    && (detail::is_implicitly_constructible<value_type, T> || detail::is_implicitly_constructible<error_type, T>) )))
0425   basic_result(T && /*unused*/, implicit_constructors_disabled_tag /*unused*/ = implicit_constructors_disabled_tag()) =
0426   delete;  // NOLINT Implicit constructors disabled, use explicit in_place_type<T>, success() or failure(). see docs!
0427 
0428   /*! AWAITING HUGO JSON CONVERSION TOOL
0429 SIGNATURE NOT RECOGNISED
0430 */
0431   BOOST_OUTCOME_TEMPLATE(class T)
0432   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_value_converting_constructor<T>))
0433   constexpr basic_result(T &&t, value_converting_constructor_tag /*unused*/ = value_converting_constructor_tag()) noexcept(
0434   detail::is_nothrow_constructible<value_type, T>)  // NOLINT
0435       : base{in_place_type<typename base::value_type>, static_cast<T &&>(t)}
0436   {
0437     no_value_policy_type::on_result_construction(this, static_cast<T &&>(t));
0438   }
0439   /*! AWAITING HUGO JSON CONVERSION TOOL
0440 SIGNATURE NOT RECOGNISED
0441 */
0442   BOOST_OUTCOME_TEMPLATE(class T)
0443   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_converting_constructor<T>))
0444   constexpr basic_result(T &&t, error_converting_constructor_tag /*unused*/ = error_converting_constructor_tag()) noexcept(
0445   detail::is_nothrow_constructible<error_type, T>)  // NOLINT
0446       : base{in_place_type<typename base::error_type>, static_cast<T &&>(t)}
0447   {
0448     no_value_policy_type::on_result_construction(this, static_cast<T &&>(t));
0449   }
0450   /*! AWAITING HUGO JSON CONVERSION TOOL
0451 SIGNATURE NOT RECOGNISED
0452 */
0453   BOOST_OUTCOME_TEMPLATE(class ErrorCondEnum)
0454   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(error_type(make_error_code(ErrorCondEnum()))),  //
0455                     BOOST_OUTCOME_TPRED(predicate::template enable_error_condition_converting_constructor<ErrorCondEnum>))
0456   constexpr basic_result(ErrorCondEnum &&t, error_condition_converting_constructor_tag /*unused*/ = error_condition_converting_constructor_tag()) noexcept(
0457   noexcept(error_type(make_error_code(static_cast<ErrorCondEnum &&>(t)))))  // NOLINT
0458       : base{in_place_type<typename base::error_type>, make_error_code(t)}
0459   {
0460     no_value_policy_type::on_result_construction(this, static_cast<ErrorCondEnum &&>(t));
0461   }
0462 
0463   /*! AWAITING HUGO JSON CONVERSION TOOL
0464 SIGNATURE NOT RECOGNISED
0465 */
0466   BOOST_OUTCOME_TEMPLATE(class T)
0467   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(convert::value_or_error<basic_result, std::decay_t<T>>::enable_result_inputs || !concepts::basic_result<T>),  //
0468                     BOOST_OUTCOME_TEXPR(convert::value_or_error<basic_result, std::decay_t<T>>{}(std::declval<T>())))
0469   constexpr explicit basic_result(T &&o,
0470                                   explicit_valueorerror_converting_constructor_tag /*unused*/ = explicit_valueorerror_converting_constructor_tag())  // NOLINT
0471       : basic_result{convert::value_or_error<basic_result, std::decay_t<T>>{}(static_cast<T &&>(o))}
0472   {
0473   }
0474   /*! AWAITING HUGO JSON CONVERSION TOOL
0475 SIGNATURE NOT RECOGNISED
0476 */
0477   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0478   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
0479   constexpr explicit basic_result(
0480   const basic_result<T, U, V> &o,
0481   explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0482                                                                                                            detail::is_nothrow_constructible<error_type, U>)
0483       : base{typename base::compatible_conversion_tag(), o}
0484   {
0485     no_value_policy_type::on_result_copy_construction(this, o);
0486   }
0487   /*! AWAITING HUGO JSON CONVERSION TOOL
0488 SIGNATURE NOT RECOGNISED
0489 */
0490   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0491   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
0492   constexpr explicit basic_result(
0493   basic_result<T, U, V> &&o,
0494   explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0495                                                                                                            detail::is_nothrow_constructible<error_type, U>)
0496       : base{typename base::compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
0497   {
0498     no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
0499   }
0500   /*! AWAITING HUGO JSON CONVERSION TOOL
0501 SIGNATURE NOT RECOGNISED
0502 */
0503   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0504   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
0505   constexpr explicit basic_result(const basic_result<T, U, V> &o,
0506                                   explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ =
0507                                   explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0508                                                                                                       noexcept(make_error_code(std::declval<U>())))
0509       : base{typename base::make_error_code_compatible_conversion_tag(), o}
0510   {
0511     no_value_policy_type::on_result_copy_construction(this, o);
0512   }
0513   /*! AWAITING HUGO JSON CONVERSION TOOL
0514 SIGNATURE NOT RECOGNISED
0515 */
0516   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0517   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
0518   constexpr explicit basic_result(basic_result<T, U, V> &&o,
0519                                   explicit_make_error_code_compatible_move_conversion_tag /*unused*/ =
0520                                   explicit_make_error_code_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0521                                                                                                       noexcept(make_error_code(std::declval<U>())))
0522       : base{typename base::make_error_code_compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
0523   {
0524     no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
0525   }
0526   /*! AWAITING HUGO JSON CONVERSION TOOL
0527 SIGNATURE NOT RECOGNISED
0528 */
0529   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0530   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
0531   constexpr explicit basic_result(const basic_result<T, U, V> &o,
0532                                   explicit_make_exception_ptr_compatible_copy_conversion_tag /*unused*/ =
0533                                   explicit_make_exception_ptr_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0534                                                                                                          noexcept(make_exception_ptr(std::declval<U>())))
0535       : base{typename base::make_exception_ptr_compatible_conversion_tag(), o}
0536   {
0537     no_value_policy_type::on_result_copy_construction(this, o);
0538   }
0539   /*! AWAITING HUGO JSON CONVERSION TOOL
0540 SIGNATURE NOT RECOGNISED
0541 */
0542   BOOST_OUTCOME_TEMPLATE(class T, class U, class V)
0543   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
0544   constexpr explicit basic_result(basic_result<T, U, V> &&o,
0545                                   explicit_make_exception_ptr_compatible_move_conversion_tag /*unused*/ =
0546                                   explicit_make_exception_ptr_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&
0547                                                                                                          noexcept(make_exception_ptr(std::declval<U>())))
0548       : base{typename base::make_exception_ptr_compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
0549   {
0550     no_value_policy_type::on_result_move_construction(this, static_cast<basic_result<T, U, V> &&>(o));
0551   }
0552 
0553   /*! AWAITING HUGO JSON CONVERSION TOOL
0554 SIGNATURE NOT RECOGNISED
0555 */
0556   BOOST_OUTCOME_TEMPLATE(class... Args)
0557   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<Args...>))
0558   constexpr explicit basic_result(in_place_type_t<value_type_if_enabled> _, Args &&...args) noexcept(detail::is_nothrow_constructible<value_type, Args...>)
0559       : base{_, static_cast<Args &&>(args)...}
0560   {
0561     no_value_policy_type::on_result_in_place_construction(this, in_place_type<value_type>, static_cast<Args &&>(args)...);
0562   }
0563   /*! AWAITING HUGO JSON CONVERSION TOOL
0564 SIGNATURE NOT RECOGNISED
0565 */
0566   BOOST_OUTCOME_TEMPLATE(class U, class... Args)
0567   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<std::initializer_list<U>, Args...>))
0568   constexpr explicit basic_result(in_place_type_t<value_type_if_enabled> _, std::initializer_list<U> il,
0569                                   Args &&...args) noexcept(detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
0570       : base{_, il, static_cast<Args &&>(args)...}
0571   {
0572     no_value_policy_type::on_result_in_place_construction(this, in_place_type<value_type>, il, static_cast<Args &&>(args)...);
0573   }
0574   /*! AWAITING HUGO JSON CONVERSION TOOL
0575 SIGNATURE NOT RECOGNISED
0576 */
0577   BOOST_OUTCOME_TEMPLATE(class... Args)
0578   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<Args...>))
0579   constexpr explicit basic_result(in_place_type_t<error_type_if_enabled> _, Args &&...args) noexcept(detail::is_nothrow_constructible<error_type, Args...>)
0580       : base{_, static_cast<Args &&>(args)...}
0581   {
0582     no_value_policy_type::on_result_in_place_construction(this, in_place_type<error_type>, static_cast<Args &&>(args)...);
0583   }
0584   /*! AWAITING HUGO JSON CONVERSION TOOL
0585 SIGNATURE NOT RECOGNISED
0586 */
0587   BOOST_OUTCOME_TEMPLATE(class U, class... Args)
0588   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<std::initializer_list<U>, Args...>))
0589   constexpr explicit basic_result(in_place_type_t<error_type_if_enabled> _, std::initializer_list<U> il,
0590                                   Args &&...args) noexcept(detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
0591       : base{_, il, static_cast<Args &&>(args)...}
0592   {
0593     no_value_policy_type::on_result_in_place_construction(this, in_place_type<error_type>, il, static_cast<Args &&>(args)...);
0594   }
0595   /*! AWAITING HUGO JSON CONVERSION TOOL
0596 SIGNATURE NOT RECOGNISED
0597 */
0598   BOOST_OUTCOME_TEMPLATE(class A1, class A2, class... Args)
0599   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_error_constructor<A1, A2, Args...>))
0600   constexpr basic_result(A1 &&a1, A2 &&a2, Args &&...args) noexcept(noexcept(
0601   typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>(std::declval<A1>(), std::declval<A2>(), std::declval<Args>()...)))
0602       : basic_result(in_place_type<typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>>, static_cast<A1 &&>(a1),
0603                      static_cast<A2 &&>(a2), static_cast<Args &&>(args)...)
0604   {
0605   }
0606 
0607   /*! AWAITING HUGO JSON CONVERSION TOOL
0608 SIGNATURE NOT RECOGNISED
0609 */
0610   constexpr basic_result(const success_type<void> &o) noexcept(std::is_nothrow_default_constructible<value_type>::value)  // NOLINT
0611       : base{in_place_type<value_type_if_enabled>}
0612   {
0613     hooks::set_spare_storage(this, o.spare_storage());
0614     no_value_policy_type::on_result_copy_construction(this, o);
0615   }
0616   /*! AWAITING HUGO JSON CONVERSION TOOL
0617 SIGNATURE NOT RECOGNISED
0618 */
0619   BOOST_OUTCOME_TEMPLATE(class T)
0620   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, void, void>))
0621   constexpr basic_result(const success_type<T> &o) noexcept(detail::is_nothrow_constructible<value_type, T>)  // NOLINT
0622       : base{in_place_type<value_type_if_enabled>, detail::extract_value_from_success<value_type>(o)}
0623   {
0624     hooks::set_spare_storage(this, o.spare_storage());
0625     no_value_policy_type::on_result_copy_construction(this, o);
0626   }
0627   /*! AWAITING HUGO JSON CONVERSION TOOL
0628 SIGNATURE NOT RECOGNISED
0629 */
0630   BOOST_OUTCOME_TEMPLATE(class T)
0631   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<T, void, void>))
0632   constexpr basic_result(success_type<T> &&o) noexcept(detail::is_nothrow_constructible<value_type, T>)  // NOLINT
0633       : base{in_place_type<value_type_if_enabled>, detail::extract_value_from_success<value_type>(static_cast<success_type<T> &&>(o))}
0634   {
0635     hooks::set_spare_storage(this, o.spare_storage());
0636     no_value_policy_type::on_result_move_construction(this, static_cast<success_type<T> &&>(o));
0637   }
0638   /*! AWAITING HUGO JSON CONVERSION TOOL
0639 SIGNATURE NOT RECOGNISED
0640 */
0641   BOOST_OUTCOME_TEMPLATE(class T)
0642   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion<void, T, void>))
0643   constexpr basic_result(const failure_type<T> &o, explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(
0644   detail::is_nothrow_constructible<error_type, T>)  // NOLINT
0645       : base{in_place_type<error_type_if_enabled>, detail::extract_error_from_failure<error_type>(o)}
0646   {
0647     hooks::set_spare_storage(this, o.spare_storage());
0648     no_value_policy_type::on_result_copy_construction(this, o);
0649   }
0650   /*! AWAITING HUGO JSON CONVERSION TOOL
0651 SIGNATURE NOT RECOGNISED
0652 */
0653   BOOST_OUTCOME_TEMPLATE(class T)
0654   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion<void, T, void>))
0655   constexpr basic_result(failure_type<T> &&o, explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(
0656   detail::is_nothrow_constructible<error_type, T>)  // NOLINT
0657       : base{in_place_type<error_type_if_enabled>, detail::extract_error_from_failure<error_type>(static_cast<failure_type<T> &&>(o))}
0658   {
0659     hooks::set_spare_storage(this, o.spare_storage());
0660     no_value_policy_type::on_result_move_construction(this, static_cast<failure_type<T> &&>(o));
0661   }
0662   /*! AWAITING HUGO JSON CONVERSION TOOL
0663 SIGNATURE NOT RECOGNISED
0664 */
0665   BOOST_OUTCOME_TEMPLATE(class T)
0666   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<void, T, void>))
0667   constexpr basic_result(const failure_type<T> &o,
0668                          explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ =
0669                          explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(noexcept(make_error_code(std::declval<T>())))  // NOLINT
0670       : base{in_place_type<error_type_if_enabled>, make_error_code(detail::extract_error_from_failure<error_type>(o))}
0671   {
0672     hooks::set_spare_storage(this, o.spare_storage());
0673     no_value_policy_type::on_result_copy_construction(this, o);
0674   }
0675   /*! AWAITING HUGO JSON CONVERSION TOOL
0676 SIGNATURE NOT RECOGNISED
0677 */
0678   BOOST_OUTCOME_TEMPLATE(class T)
0679   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<void, T, void>))
0680   constexpr basic_result(failure_type<T> &&o,
0681                          explicit_make_error_code_compatible_move_conversion_tag /*unused*/ =
0682                          explicit_make_error_code_compatible_move_conversion_tag()) noexcept(noexcept(make_error_code(std::declval<T>())))  // NOLINT
0683       : base{in_place_type<error_type_if_enabled>, make_error_code(detail::extract_error_from_failure<error_type>(static_cast<failure_type<T> &&>(o)))}
0684   {
0685     hooks::set_spare_storage(this, o.spare_storage());
0686     no_value_policy_type::on_result_move_construction(this, static_cast<failure_type<T> &&>(o));
0687   }
0688   /*! AWAITING HUGO JSON CONVERSION TOOL
0689 SIGNATURE NOT RECOGNISED
0690 */
0691   BOOST_OUTCOME_TEMPLATE(class T)
0692   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<void, T, void>))
0693   constexpr basic_result(const failure_type<T> &o,
0694                          explicit_make_exception_ptr_compatible_copy_conversion_tag /*unused*/ =
0695                          explicit_make_exception_ptr_compatible_copy_conversion_tag()) noexcept(noexcept(make_exception_ptr(std::declval<T>())))  // NOLINT
0696       : base{in_place_type<error_type_if_enabled>, make_exception_ptr(detail::extract_error_from_failure<error_type>(o))}
0697   {
0698     hooks::set_spare_storage(this, o.spare_storage());
0699     no_value_policy_type::on_result_copy_construction(this, o);
0700   }
0701   /*! AWAITING HUGO JSON CONVERSION TOOL
0702 SIGNATURE NOT RECOGNISED
0703 */
0704   BOOST_OUTCOME_TEMPLATE(class T)
0705   BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<void, T, void>))
0706   constexpr basic_result(failure_type<T> &&o,
0707                          explicit_make_exception_ptr_compatible_move_conversion_tag /*unused*/ =
0708                          explicit_make_exception_ptr_compatible_move_conversion_tag()) noexcept(noexcept(make_exception_ptr(std::declval<T>())))  // NOLINT
0709       : base{in_place_type<error_type_if_enabled>, make_exception_ptr(detail::extract_error_from_failure<error_type>(static_cast<failure_type<T> &&>(o)))}
0710   {
0711     hooks::set_spare_storage(this, o.spare_storage());
0712     no_value_policy_type::on_result_move_construction(this, static_cast<failure_type<T> &&>(o));
0713   }
0714 
0715   /*! AWAITING HUGO JSON CONVERSION TOOL
0716 SIGNATURE NOT RECOGNISED
0717 */
0718   constexpr void swap(basic_result &o) noexcept((std::is_void<value_type>::value || detail::is_nothrow_swappable<value_type>::value)  //
0719                                                 && (std::is_void<error_type>::value || detail::is_nothrow_swappable<error_type>::value))
0720   {
0721     this->_state.swap(o._state);
0722   }
0723 
0724   /*! AWAITING HUGO JSON CONVERSION TOOL
0725 SIGNATURE NOT RECOGNISED
0726 */
0727   auto as_failure() const & { return failure(this->assume_error(), hooks::spare_storage(this)); }
0728   /*! AWAITING HUGO JSON CONVERSION TOOL
0729 SIGNATURE NOT RECOGNISED
0730 */
0731   auto as_failure() &&
0732   {
0733     this->_state._status.set_have_moved_from(true);
0734     return failure(static_cast<basic_result &&>(*this).assume_error(), hooks::spare_storage(this));
0735   }
0736 
0737 #ifdef __APPLE__
0738   failure_type<error_type> _xcode_workaround_as_failure() &&;
0739 #endif
0740 };
0741 
0742 /*! AWAITING HUGO JSON CONVERSION TOOL
0743 SIGNATURE NOT RECOGNISED
0744 */
0745 template <class R, class S, class P> inline void swap(basic_result<R, S, P> &a, basic_result<R, S, P> &b) noexcept(noexcept(a.swap(b)))
0746 {
0747   a.swap(b);
0748 }
0749 
0750 #if !defined(NDEBUG)
0751 // Check is trivial in all ways except default constructibility
0752 // static_assert(std::is_trivial<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivial!");
0753 // static_assert(std::is_trivially_default_constructible<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially default
0754 // constructible!");
0755 static_assert(std::is_trivially_copyable<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially copyable!");
0756 static_assert(std::is_trivially_assignable<basic_result<int, long, policy::all_narrow>, basic_result<int, long, policy::all_narrow>>::value,
0757               "result<int> is not trivially assignable!");
0758 static_assert(std::is_trivially_destructible<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially destructible!");
0759 static_assert(std::is_trivially_copy_constructible<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially copy constructible!");
0760 static_assert(std::is_trivially_move_constructible<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially move constructible!");
0761 static_assert(std::is_trivially_copy_assignable<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially copy assignable!");
0762 static_assert(std::is_trivially_move_assignable<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not trivially move assignable!");
0763 // Also check is standard layout
0764 static_assert(std::is_standard_layout<basic_result<int, long, policy::all_narrow>>::value, "result<int> is not a standard layout type!");
0765 #endif
0766 
0767 BOOST_OUTCOME_V2_NAMESPACE_END
0768 
0769 #if defined(_MSC_VER) && !defined(__clang__)
0770 #pragma warning(pop)
0771 #endif
0772 
0773 #ifdef __clang__
0774 #pragma clang diagnostic pop
0775 #endif
0776 
0777 #endif