struct disable_inplace_value_error_exception_constructor;
template <class... Args>
using choose_inplace_value_error_exception_constructor = std::conditional_t< //
- ((static_cast<int>(std::is_constructible<value_type, Args...>::value) + static_cast<int>(std::is_constructible<error_type, Args...>::value) +
- static_cast<int>(std::is_constructible<exception_type, Args...>::value)) > 1), //
- disable_inplace_value_error_exception_constructor, //
- std::conditional_t< //
- std::is_constructible<value_type, Args...>::value, //
- value_type, //
- std::conditional_t< //
- std::is_constructible<error_type, Args...>::value, //
- error_type, //
- std::conditional_t< //
- std::is_constructible<exception_type, Args...>::value, //
- exception_type, //
+ ((static_cast<int>(detail::is_constructible<value_type, Args...>) + static_cast<int>(detail::is_constructible<error_type, Args...>) +
+ static_cast<int>(detail::is_constructible<exception_type, Args...>)) > 1), //
+ disable_inplace_value_error_exception_constructor, //
+ std::conditional_t< //
+ detail::is_constructible<value_type, Args...>, //
+ value_type, //
+ std::conditional_t< //
+ detail::is_constructible<error_type, Args...>, //
+ error_type, //
+ std::conditional_t< //
+ detail::is_constructible<exception_type, Args...>, //
+ exception_type, //
disable_inplace_value_error_exception_constructor>>>>;
template <class... Args>
static constexpr bool enable_inplace_value_error_exception_constructor = //
*/
template <class T> static constexpr bool is_basic_outcome_v = detail::is_basic_outcome<std::decay_t<T>>::value;
+namespace concepts
+{
+#if defined(__cpp_concepts)
+ /* The `basic_outcome` concept.
+ \requires That `U` matches a `basic_outcome`.
+ */
+ template <class U>
+ concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL basic_outcome =
+ BOOST_OUTCOME_V2_NAMESPACE::is_basic_outcome<U>::value ||
+ (requires(U v) {
+ BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<typename U::value_type, typename U::error_type, typename U::exception_type, typename U::no_value_policy_type>(v);
+ } && //
+ detail::convertible<
+ U, BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<typename U::value_type, typename U::error_type, typename U::exception_type, typename U::no_value_policy_type>> && //
+ detail::base_of<
+ BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<typename U::value_type, typename U::error_type, typename U::exception_type, typename U::no_value_policy_type>, U>);
+#else
+ namespace detail
+ {
+ inline no_match match_basic_outcome(...);
+ template <class R, class S, class P, class NVP, class T, //
+ typename = typename T::value_type, //
+ typename = typename T::error_type, //
+ typename = typename T::exception_type, //
+ typename = typename T::no_value_policy_type, //
+ typename std::enable_if_t<std::is_convertible<T, BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<R, S, P, NVP>>::value && //
+ std::is_base_of<BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<R, S, P, NVP>, T>::value,
+ bool> = true>
+ inline BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<R, S, P, NVP> match_basic_outcome(BOOST_OUTCOME_V2_NAMESPACE::basic_outcome<R, S, P, NVP> &&, T &&);
+
+ template <class U>
+ static constexpr bool basic_outcome =
+ BOOST_OUTCOME_V2_NAMESPACE::is_basic_outcome<U>::value ||
+ !std::is_same<no_match, decltype(match_basic_outcome(std::declval<BOOST_OUTCOME_V2_NAMESPACE::detail::devoid<U>>(),
+ std::declval<BOOST_OUTCOME_V2_NAMESPACE::detail::devoid<U>>()))>::value;
+ } // namespace detail
+ /* The `basic_outcome` concept.
+ \requires That `U` matches a `basic_outcome`.
+ */
+ template <class U> static constexpr bool basic_outcome = detail::basic_outcome<U>;
+#endif
+} // namespace concepts
+
namespace hooks
{
/*! AWAITING HUGO JSON CONVERSION TOOL
using value_type = R;
using error_type = S;
using exception_type = P;
+ using no_value_policy_type = NoValuePolicy;
template <class T, class U = S, class V = P, class W = NoValuePolicy> using rebind = basic_outcome<T, U, V, W>;
static constexpr bool enable_inplace_value_constructor = //
constructors_enabled //
&& (std::is_void<value_type>::value //
- || std::is_constructible<value_type, Args...>::value);
+ || detail::is_constructible<value_type, Args...>);
// Predicate for the inplace construction of error to be available.
template <class... Args>
static constexpr bool enable_inplace_error_constructor = //
constructors_enabled //
&& (std::is_void<error_type>::value //
- || std::is_constructible<error_type, Args...>::value);
+ || detail::is_constructible<error_type, Args...>);
// Predicate for the inplace construction of exception to be available.
template <class... Args>
static constexpr bool enable_inplace_exception_constructor = //
constructors_enabled //
&& (std::is_void<exception_type>::value //
- || std::is_constructible<exception_type, Args...>::value);
+ || detail::is_constructible<exception_type, Args...>);
// Predicate for the implicit converting inplace constructor to be available.
template <class... Args>
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_value_converting_constructor<T>))
constexpr basic_outcome(T &&t, value_converting_constructor_tag /*unused*/ = value_converting_constructor_tag()) noexcept(
- std::is_nothrow_constructible<value_type, T>::value) // NOLINT
+ detail::is_nothrow_constructible<value_type, T>) // NOLINT
: base{in_place_type<typename base::_value_type>, static_cast<T &&>(t)}
, _ptr()
{
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_converting_constructor<T>))
constexpr basic_outcome(T &&t, error_converting_constructor_tag /*unused*/ = error_converting_constructor_tag()) noexcept(
- std::is_nothrow_constructible<error_type, T>::value) // NOLINT
+ detail::is_nothrow_constructible<error_type, T>) // NOLINT
: base{in_place_type<typename base::_error_type>, static_cast<T &&>(t)}
, _ptr()
{
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_exception_converting_constructor<T>))
constexpr basic_outcome(T &&t, exception_converting_constructor_tag /*unused*/ = exception_converting_constructor_tag()) noexcept(
- std::is_nothrow_constructible<exception_type, T>::value) // NOLINT
+ detail::is_nothrow_constructible<exception_type, T>) // NOLINT
: base()
, _ptr(static_cast<T &&>(t))
{
BOOST_OUTCOME_TEMPLATE(class T, class U)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_exception_converting_constructor<T, U>))
constexpr basic_outcome(T &&a, U &&b, error_exception_converting_constructor_tag /*unused*/ = error_exception_converting_constructor_tag()) noexcept(
- std::is_nothrow_constructible<error_type, T>::value &&std::is_nothrow_constructible<exception_type, U>::value) // NOLINT
+ detail::is_nothrow_constructible<error_type, T> &&detail::is_nothrow_constructible<exception_type, U>) // NOLINT
: base{in_place_type<typename base::_error_type>, static_cast<T &&>(a)}
, _ptr(static_cast<U &&>(b))
{
SIGNATURE NOT RECOGNISED
*/
BOOST_OUTCOME_TEMPLATE(class T)
- BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(convert::value_or_error<basic_outcome, std::decay_t<T>>::enable_result_inputs || !is_basic_result_v<T>), //
- BOOST_OUTCOME_TPRED(convert::value_or_error<basic_outcome, std::decay_t<T>>::enable_outcome_inputs || !is_basic_outcome_v<T>), //
+ BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(convert::value_or_error<basic_outcome, std::decay_t<T>>::enable_result_inputs || !concepts::basic_result<T>), //
+ BOOST_OUTCOME_TPRED(convert::value_or_error<basic_outcome, std::decay_t<T>>::enable_outcome_inputs || !concepts::basic_outcome<T>), //
BOOST_OUTCOME_TEXPR(convert::value_or_error<basic_outcome, std::decay_t<T>>{}(std::declval<T>())))
constexpr explicit basic_outcome(T &&o,
explicit_valueorerror_converting_constructor_tag /*unused*/ = explicit_valueorerror_converting_constructor_tag()) // NOLINT
constexpr explicit basic_outcome(
const basic_outcome<T, U, V, W> &o,
explicit_compatible_copy_conversion_tag /*unused*/ =
- explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value &&std::is_nothrow_constructible<error_type, U>::value
- &&std::is_nothrow_constructible<exception_type, V>::value)
+ explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>
+ &&detail::is_nothrow_constructible<exception_type, V>)
: base{typename base::compatible_conversion_tag(), o}
, _ptr(o._ptr)
{
constexpr explicit basic_outcome(
basic_outcome<T, U, V, W> &&o,
explicit_compatible_move_conversion_tag /*unused*/ =
- explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value &&std::is_nothrow_constructible<error_type, U>::value
- &&std::is_nothrow_constructible<exception_type, V>::value)
+ explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>
+ &&detail::is_nothrow_constructible<exception_type, V>)
: base{typename base::compatible_conversion_tag(), static_cast<basic_outcome<T, U, V, W> &&>(o)}
, _ptr(static_cast<typename basic_outcome<T, U, V, W>::exception_type &&>(o._ptr))
{
constexpr explicit basic_outcome(
const basic_result<T, U, V> &o,
explicit_compatible_copy_conversion_tag /*unused*/ =
- explicit_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value &&std::is_nothrow_constructible<error_type, U>::value
- &&std::is_nothrow_constructible<exception_type>::value)
+ explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>
+ &&detail::is_nothrow_constructible<exception_type>)
: base{typename base::compatible_conversion_tag(), o}
, _ptr()
{
constexpr explicit basic_outcome(
basic_result<T, U, V> &&o,
explicit_compatible_move_conversion_tag /*unused*/ =
- explicit_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value &&std::is_nothrow_constructible<error_type, U>::value
- &&std::is_nothrow_constructible<exception_type>::value)
+ explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T> &&detail::is_nothrow_constructible<error_type, U>
+ &&detail::is_nothrow_constructible<exception_type>)
: base{typename base::compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
, _ptr()
{
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates<value_type, error_type>::template enable_make_error_code_compatible_conversion<T, U, V>))
constexpr explicit basic_outcome(const basic_result<T, U, V> &o,
explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ =
- explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value
+ explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_error_code(std::declval<U>())) &&
- std::is_nothrow_constructible<exception_type>::value)
+ detail::is_nothrow_constructible<exception_type>)
: base{typename base::make_error_code_compatible_conversion_tag(), o}
, _ptr()
{
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates<value_type, error_type>::template enable_make_error_code_compatible_conversion<T, U, V>))
constexpr explicit basic_outcome(basic_result<T, U, V> &&o,
explicit_make_error_code_compatible_move_conversion_tag /*unused*/ =
- explicit_make_error_code_compatible_move_conversion_tag()) noexcept(std::is_nothrow_constructible<value_type, T>::value
+ explicit_make_error_code_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible<value_type, T>
&&noexcept(make_error_code(std::declval<U>())) &&
- std::is_nothrow_constructible<exception_type>::value)
+ detail::is_nothrow_constructible<exception_type>)
: base{typename base::make_error_code_compatible_conversion_tag(), static_cast<basic_result<T, U, V> &&>(o)}
, _ptr()
{
*/
BOOST_OUTCOME_TEMPLATE(class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<Args...>))
- constexpr explicit basic_outcome(in_place_type_t<value_type_if_enabled> _,
- Args &&... args) noexcept(std::is_nothrow_constructible<value_type, Args...>::value)
+ constexpr explicit basic_outcome(in_place_type_t<value_type_if_enabled> _, Args &&... args) noexcept(detail::is_nothrow_constructible<value_type, Args...>)
: base{_, static_cast<Args &&>(args)...}
, _ptr()
{
BOOST_OUTCOME_TEMPLATE(class U, class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<std::initializer_list<U>, Args...>))
constexpr explicit basic_outcome(in_place_type_t<value_type_if_enabled> _, std::initializer_list<U> il,
- Args &&... args) noexcept(std::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>::value)
+ Args &&... args) noexcept(detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
: base{_, il, static_cast<Args &&>(args)...}
, _ptr()
{
*/
BOOST_OUTCOME_TEMPLATE(class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<Args...>))
- constexpr explicit basic_outcome(in_place_type_t<error_type_if_enabled> _,
- Args &&... args) noexcept(std::is_nothrow_constructible<error_type, Args...>::value)
+ constexpr explicit basic_outcome(in_place_type_t<error_type_if_enabled> _, Args &&... args) noexcept(detail::is_nothrow_constructible<error_type, Args...>)
: base{_, static_cast<Args &&>(args)...}
, _ptr()
{
BOOST_OUTCOME_TEMPLATE(class U, class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<std::initializer_list<U>, Args...>))
constexpr explicit basic_outcome(in_place_type_t<error_type_if_enabled> _, std::initializer_list<U> il,
- Args &&... args) noexcept(std::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>::value)
+ Args &&... args) noexcept(detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
: base{_, il, static_cast<Args &&>(args)...}
, _ptr()
{
BOOST_OUTCOME_TEMPLATE(class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor<Args...>))
constexpr explicit basic_outcome(in_place_type_t<exception_type_if_enabled> /*unused*/,
- Args &&... args) noexcept(std::is_nothrow_constructible<exception_type, Args...>::value)
+ Args &&... args) noexcept(detail::is_nothrow_constructible<exception_type, Args...>)
: base()
, _ptr(static_cast<Args &&>(args)...)
{
BOOST_OUTCOME_TEMPLATE(class U, class... Args)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor<std::initializer_list<U>, Args...>))
constexpr explicit basic_outcome(in_place_type_t<exception_type_if_enabled> /*unused*/, std::initializer_list<U> il,
- Args &&... args) noexcept(std::is_nothrow_constructible<exception_type, std::initializer_list<U>, Args...>::value)
+ Args &&... args) noexcept(detail::is_nothrow_constructible<exception_type, std::initializer_list<U>, Args...>)
: base()
, _ptr(il, static_cast<Args &&>(args)...)
{
*/
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<T, void, void, void>))
- constexpr basic_outcome(const success_type<T> &o) noexcept(std::is_nothrow_constructible<value_type, T>::value) // NOLINT
+ constexpr basic_outcome(const success_type<T> &o) noexcept(detail::is_nothrow_constructible<value_type, T>) // NOLINT
: base{in_place_type<typename base::_value_type>, detail::extract_value_from_success<value_type>(o)}
{
using namespace hooks;
*/
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<T, void, void, void>))
- constexpr basic_outcome(success_type<T> &&o) noexcept(std::is_nothrow_constructible<value_type, T>::value) // NOLINT
+ constexpr basic_outcome(success_type<T> &&o) noexcept(detail::is_nothrow_constructible<value_type, T>) // NOLINT
: base{in_place_type<typename base::_value_type>, detail::extract_value_from_success<value_type>(static_cast<success_type<T> &&>(o))}
{
using namespace hooks;
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<void, T, void, void>))
constexpr basic_outcome(const failure_type<T> &o,
- error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible<error_type, T>::value) // NOLINT
+ error_failure_tag /*unused*/ = error_failure_tag()) noexcept(detail::is_nothrow_constructible<error_type, T>) // NOLINT
: base{in_place_type<typename base::_error_type>, detail::extract_error_from_failure<error_type>(o)}
, _ptr()
{
*/
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<void, void, T, void>))
- constexpr basic_outcome(const failure_type<T> &o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(
- std::is_nothrow_constructible<exception_type, T>::value) // NOLINT
+ constexpr basic_outcome(const failure_type<T> &o,
+ exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(detail::is_nothrow_constructible<exception_type, T>) // NOLINT
: base()
, _ptr(detail::extract_exception_from_failure<exception_type>(o))
{
BOOST_OUTCOME_TEMPLATE(class T, class U)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<U>::value && predicate::template enable_compatible_conversion<void, T, U, void>))
constexpr basic_outcome(const failure_type<T, U> &o, explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept(
- std::is_nothrow_constructible<error_type, T>::value &&std::is_nothrow_constructible<exception_type, U>::value) // NOLINT
+ detail::is_nothrow_constructible<error_type, T> &&detail::is_nothrow_constructible<exception_type, U>) // NOLINT
: base{in_place_type<typename base::_error_type>, detail::extract_error_from_failure<error_type>(o)}
, _ptr(detail::extract_exception_from_failure<exception_type>(o))
{
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<void, T, void, void>))
constexpr basic_outcome(failure_type<T> &&o,
- error_failure_tag /*unused*/ = error_failure_tag()) noexcept(std::is_nothrow_constructible<error_type, T>::value) // NOLINT
+ error_failure_tag /*unused*/ = error_failure_tag()) noexcept(detail::is_nothrow_constructible<error_type, T>) // NOLINT
: base{in_place_type<typename base::_error_type>, detail::extract_error_from_failure<error_type>(static_cast<failure_type<T> &&>(o))}
, _ptr()
{
*/
BOOST_OUTCOME_TEMPLATE(class T)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<T>::value && predicate::template enable_compatible_conversion<void, void, T, void>))
- constexpr basic_outcome(failure_type<T> &&o, exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(
- std::is_nothrow_constructible<exception_type, T>::value) // NOLINT
+ constexpr basic_outcome(failure_type<T> &&o,
+ exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(detail::is_nothrow_constructible<exception_type, T>) // NOLINT
: base()
, _ptr(detail::extract_exception_from_failure<exception_type>(static_cast<failure_type<T> &&>(o)))
{
BOOST_OUTCOME_TEMPLATE(class T, class U)
BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void<U>::value && predicate::template enable_compatible_conversion<void, T, U, void>))
constexpr basic_outcome(failure_type<T, U> &&o, explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept(
- std::is_nothrow_constructible<error_type, T>::value &&std::is_nothrow_constructible<exception_type, U>::value) // NOLINT
+ detail::is_nothrow_constructible<error_type, T> &&detail::is_nothrow_constructible<exception_type, U>) // NOLINT
: base{in_place_type<typename base::_error_type>, detail::extract_error_from_failure<error_type>(static_cast<failure_type<T, U> &&>(o))}
, _ptr(detail::extract_exception_from_failure<exception_type>(static_cast<failure_type<T, U> &&>(o)))
{
}
return failure_type<error_type, exception_type>(in_place_type<error_type>, static_cast<S &&>(this->assume_error()));
}
+
+#ifdef __APPLE__
+ failure_type<error_type, exception_type> _xcode_workaround_as_failure() &&;
+#endif
};
+// C++ 20 operator== rewriting should take care of this for us, indeed
+// if we don't disable it, we cause Concept recursion to infinity!
+#if __cplusplus < 202000L
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/
{
return b == a;
}
+#endif
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/