1
1
/* A very simple result type
2
- (C) 2017-2021 Niall Douglas <http://www.nedproductions.biz/> (14 commits)
2
+ (C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (14 commits)
3
3
File Created: June 2017
4
4
5
5
@@ -28,6 +28,7 @@ Distributed under the Boost Software License, Version 1.0.
28
28
#include " config.hpp"
29
29
#include " convert.hpp"
30
30
#include " detail/basic_result_final.hpp"
31
+ #include " outcome_gdb.h"
31
32
32
33
#include " policy/all_narrow.hpp"
33
34
#include " policy/terminate.hpp"
@@ -136,16 +137,31 @@ namespace detail
136
137
&& !std::is_same<choose_inplace_value_error_constructor<Args...>, disable_inplace_value_error_constructor>::value;
137
138
};
138
139
139
- template <class T , class U > constexpr inline const U &extract_value_from_success (const success_type<U> &v) { return v.value (); }
140
- template <class T , class U > constexpr inline U &&extract_value_from_success(success_type<U> &&v) { return static_cast <success_type<U> &&>(v).value (); }
141
- template <class T > constexpr inline T extract_value_from_success (const success_type<void > & /* unused*/ ) { return T{}; }
140
+ template <class T , class U > constexpr inline const U &extract_value_from_success (const success_type<U> &v)
141
+ {
142
+ return v.value ();
143
+ }
144
+ template <class T , class U > constexpr inline U &&extract_value_from_success(success_type<U> &&v)
145
+ {
146
+ return static_cast <success_type<U> &&>(v).value ();
147
+ }
148
+ template <class T > constexpr inline T extract_value_from_success (const success_type<void > & /* unused*/ )
149
+ {
150
+ return T{};
151
+ }
142
152
143
- template <class T , class U , class V > constexpr inline const U &extract_error_from_failure (const failure_type<U, V> &v) { return v.error (); }
153
+ template <class T , class U , class V > constexpr inline const U &extract_error_from_failure (const failure_type<U, V> &v)
154
+ {
155
+ return v.error ();
156
+ }
144
157
template <class T , class U , class V > constexpr inline U &&extract_error_from_failure(failure_type<U, V> &&v)
145
158
{
146
159
return static_cast <failure_type<U, V> &&>(v).error ();
147
160
}
148
- template <class T , class V > constexpr inline T extract_error_from_failure (const failure_type<void , V> & /* unused*/ ) { return T{}; }
161
+ template <class T , class V > constexpr inline T extract_error_from_failure (const failure_type<void , V> & /* unused*/ )
162
+ {
163
+ return T{};
164
+ }
149
165
150
166
template <class T > struct is_basic_result
151
167
{
@@ -355,7 +371,7 @@ class OUTCOME_NODISCARD basic_result : public detail::basic_result_final<R, S, N
355
371
template <class ... Args>
356
372
static constexpr bool enable_inplace_value_error_constructor = //
357
373
constructors_enabled //
358
- &&base::template enable_inplace_value_error_constructor<Args...>;
374
+ && base::template enable_inplace_value_error_constructor<Args...>;
359
375
template <class ... Args> using choose_inplace_value_error_constructor = typename base::template choose_inplace_value_error_constructor<Args...>;
360
376
};
361
377
@@ -387,7 +403,7 @@ SIGNATURE NOT RECOGNISED
387
403
*/
388
404
OUTCOME_TEMPLATE (class Arg , class ... Args)
389
405
OUTCOME_TREQUIRES (OUTCOME_TPRED(!predicate::constructors_enabled && (sizeof ...(Args) >= 0 )))
390
- basic_result (Arg && /* unused*/ , Args &&... /* unused*/ ) = delete ; // NOLINT basic_result<T, T> is NOT SUPPORTED, see docs!
406
+ basic_result (Arg && /* unused*/ , Args &&.../* unused*/ ) = delete ; // NOLINT basic_result<T, T> is NOT SUPPORTED, see docs!
391
407
392
408
/* ! AWAITING HUGO JSON CONVERSION TOOL
393
409
SIGNATURE NOT RECOGNISED
@@ -451,8 +467,8 @@ SIGNATURE NOT RECOGNISED
451
467
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
452
468
constexpr explicit basic_result(
453
469
const basic_result<T, U, V> &o,
454
- explicit_compatible_copy_conversion_tag /* unused*/ =
455
- explicit_compatible_copy_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> && detail::is_nothrow_constructible<error_type, U>)
470
+ explicit_compatible_copy_conversion_tag /* unused*/ = explicit_compatible_copy_conversion_tag()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
471
+ detail::is_nothrow_constructible<error_type, U>)
456
472
: base{typename base::compatible_conversion_tag (), o}
457
473
{
458
474
no_value_policy_type::on_result_copy_construction (this , o);
@@ -464,8 +480,8 @@ SIGNATURE NOT RECOGNISED
464
480
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_compatible_conversion<T, U, V>))
465
481
constexpr explicit basic_result(
466
482
basic_result<T, U, V> &&o,
467
- explicit_compatible_move_conversion_tag /* unused*/ =
468
- explicit_compatible_move_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> && detail::is_nothrow_constructible<error_type, U>)
483
+ explicit_compatible_move_conversion_tag /* unused*/ = explicit_compatible_move_conversion_tag()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
484
+ detail::is_nothrow_constructible<error_type, U>)
469
485
: base{typename base::compatible_conversion_tag (), static_cast <basic_result<T, U, V> &&>(o)}
470
486
{
471
487
no_value_policy_type::on_result_move_construction (this , static_cast <basic_result<T, U, V> &&>(o));
@@ -477,8 +493,8 @@ SIGNATURE NOT RECOGNISED
477
493
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
478
494
constexpr explicit basic_result(const basic_result<T, U, V> &o,
479
495
explicit_make_error_code_compatible_copy_conversion_tag /* unused*/ =
480
- explicit_make_error_code_compatible_copy_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T>
481
- && noexcept (make_error_code(std::declval<U>())))
496
+ explicit_make_error_code_compatible_copy_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
497
+ noexcept (make_error_code(std::declval<U>())))
482
498
: base{typename base::make_error_code_compatible_conversion_tag (), o}
483
499
{
484
500
no_value_policy_type::on_result_copy_construction (this , o);
@@ -490,8 +506,8 @@ SIGNATURE NOT RECOGNISED
490
506
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_error_code_compatible_conversion<T, U, V>))
491
507
constexpr explicit basic_result(basic_result<T, U, V> &&o,
492
508
explicit_make_error_code_compatible_move_conversion_tag /* unused*/ =
493
- explicit_make_error_code_compatible_move_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T>
494
- && noexcept (make_error_code(std::declval<U>())))
509
+ explicit_make_error_code_compatible_move_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
510
+ noexcept (make_error_code(std::declval<U>())))
495
511
: base{typename base::make_error_code_compatible_conversion_tag (), static_cast <basic_result<T, U, V> &&>(o)}
496
512
{
497
513
no_value_policy_type::on_result_move_construction (this , static_cast <basic_result<T, U, V> &&>(o));
@@ -503,8 +519,8 @@ SIGNATURE NOT RECOGNISED
503
519
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
504
520
constexpr explicit basic_result(const basic_result<T, U, V> &o,
505
521
explicit_make_exception_ptr_compatible_copy_conversion_tag /* unused*/ =
506
- explicit_make_exception_ptr_compatible_copy_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T>
507
- && noexcept (make_exception_ptr(std::declval<U>())))
522
+ explicit_make_exception_ptr_compatible_copy_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
523
+ noexcept (make_exception_ptr(std::declval<U>())))
508
524
: base{typename base::make_exception_ptr_compatible_conversion_tag (), o}
509
525
{
510
526
no_value_policy_type::on_result_copy_construction (this , o);
@@ -516,8 +532,8 @@ SIGNATURE NOT RECOGNISED
516
532
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_make_exception_ptr_compatible_conversion<T, U, V>))
517
533
constexpr explicit basic_result(basic_result<T, U, V> &&o,
518
534
explicit_make_exception_ptr_compatible_move_conversion_tag /* unused*/ =
519
- explicit_make_exception_ptr_compatible_move_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T>
520
- && noexcept (make_exception_ptr(std::declval<U>())))
535
+ explicit_make_exception_ptr_compatible_move_conversion_tag ()) noexcept (detail::is_nothrow_constructible<value_type, T> &&
536
+ noexcept (make_exception_ptr(std::declval<U>())))
521
537
: base{typename base::make_exception_ptr_compatible_conversion_tag (), static_cast <basic_result<T, U, V> &&>(o)}
522
538
{
523
539
no_value_policy_type::on_result_move_construction (this , static_cast <basic_result<T, U, V> &&>(o));
@@ -528,7 +544,7 @@ SIGNATURE NOT RECOGNISED
528
544
*/
529
545
OUTCOME_TEMPLATE (class ... Args)
530
546
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<Args...>))
531
- constexpr explicit basic_result(in_place_type_t <value_type_if_enabled> _, Args &&... args) noexcept (detail::is_nothrow_constructible<value_type, Args...>)
547
+ constexpr explicit basic_result(in_place_type_t <value_type_if_enabled> _, Args &&...args) noexcept (detail::is_nothrow_constructible<value_type, Args...>)
532
548
: base{_, static_cast <Args &&>(args)...}
533
549
{
534
550
no_value_policy_type::on_result_in_place_construction (this , in_place_type<value_type>, static_cast <Args &&>(args)...);
@@ -539,7 +555,7 @@ SIGNATURE NOT RECOGNISED
539
555
OUTCOME_TEMPLATE (class U , class ... Args)
540
556
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_constructor<std::initializer_list<U>, Args...>))
541
557
constexpr explicit basic_result(in_place_type_t <value_type_if_enabled> _, std::initializer_list<U> il,
542
- Args &&... args) noexcept (detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
558
+ Args &&...args) noexcept (detail::is_nothrow_constructible<value_type, std::initializer_list<U>, Args...>)
543
559
: base{_, il, static_cast <Args &&>(args)...}
544
560
{
545
561
no_value_policy_type::on_result_in_place_construction (this , in_place_type<value_type>, il, static_cast <Args &&>(args)...);
@@ -549,7 +565,7 @@ SIGNATURE NOT RECOGNISED
549
565
*/
550
566
OUTCOME_TEMPLATE (class ... Args)
551
567
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<Args...>))
552
- constexpr explicit basic_result(in_place_type_t <error_type_if_enabled> _, Args &&... args) noexcept (detail::is_nothrow_constructible<error_type, Args...>)
568
+ constexpr explicit basic_result(in_place_type_t <error_type_if_enabled> _, Args &&...args) noexcept (detail::is_nothrow_constructible<error_type, Args...>)
553
569
: base{_, static_cast <Args &&>(args)...}
554
570
{
555
571
no_value_policy_type::on_result_in_place_construction (this , in_place_type<error_type>, static_cast <Args &&>(args)...);
@@ -560,7 +576,7 @@ SIGNATURE NOT RECOGNISED
560
576
OUTCOME_TEMPLATE (class U , class ... Args)
561
577
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_error_constructor<std::initializer_list<U>, Args...>))
562
578
constexpr explicit basic_result(in_place_type_t <error_type_if_enabled> _, std::initializer_list<U> il,
563
- Args &&... args) noexcept (detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
579
+ Args &&...args) noexcept (detail::is_nothrow_constructible<error_type, std::initializer_list<U>, Args...>)
564
580
: base{_, il, static_cast <Args &&>(args)...}
565
581
{
566
582
no_value_policy_type::on_result_in_place_construction (this , in_place_type<error_type>, il, static_cast <Args &&>(args)...);
@@ -570,7 +586,7 @@ SIGNATURE NOT RECOGNISED
570
586
*/
571
587
OUTCOME_TEMPLATE (class A1 , class A2 , class ... Args)
572
588
OUTCOME_TREQUIRES(OUTCOME_TPRED(predicate::template enable_inplace_value_error_constructor<A1, A2, Args...>))
573
- constexpr basic_result(A1 &&a1, A2 &&a2, Args &&... args) noexcept (noexcept (
589
+ constexpr basic_result(A1 &&a1, A2 &&a2, Args &&...args) noexcept (noexcept (
574
590
typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>(std::declval<A1>(), std::declval<A2>(), std::declval<Args>()...)))
575
591
: basic_result(in_place_type<typename predicate::template choose_inplace_value_error_constructor<A1, A2, Args...>>, static_cast <A1 &&>(a1),
576
592
static_cast<A2 &&>(a2), static_cast<Args &&>(args)...)
0 commit comments