29#ifndef _GLIBCXX_EXPECTED
30#define _GLIBCXX_EXPECTED
33#pragma GCC system_header
36#define __glibcxx_want_expected
37#define __glibcxx_want_freestanding_expected
38#define __glibcxx_want_constrained_equality
39#define __glibcxx_want_constexpr_exceptions
42#ifdef __cpp_lib_expected
49namespace std _GLIBCXX_VISIBILITY(default)
51_GLIBCXX_BEGIN_NAMESPACE_VERSION
64 template<
typename _Tp,
typename _Er>
71 template<
typename _Er>
78 template<
typename _Er>
79 class bad_expected_access;
81#if __cpp_lib_constexpr_exceptions >= 202502L
82#define _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS constexpr
84#define _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
88 class bad_expected_access<void> :
public exception
91 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS bad_expected_access() noexcept { }
92 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
93 bad_expected_access(
const bad_expected_access&)
noexcept =
default;
94 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
95 bad_expected_access(bad_expected_access&&) noexcept = default;
96 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
97 bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
98 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
99 bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
100 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
101 ~bad_expected_access() = default;
106 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS const
char*
107 what() const noexcept
override
108 {
return "bad access to std::expected without expected value"; }
111 template<
typename _Er>
112 class bad_expected_access :
public bad_expected_access<void> {
114 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
explicit
115 bad_expected_access(_Er __e) : _M_unex(std::move(__e)) { }
120 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS _Er&
125 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
const _Er&
126 error() const & noexcept
130 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS _Er&&
135 _GLIBCXX_CONSTEXPR_BAD_EXPECTED_ACCESS
const _Er&&
136 error() const && noexcept
149 explicit unexpect_t() =
default;
156 inline constexpr unexpect_t unexpect{};
161 template<
typename _Tp>
162 constexpr bool __is_expected =
false;
163 template<
typename _Tp,
typename _Er>
164 constexpr bool __is_expected<expected<_Tp, _Er>> =
true;
166 template<
typename _Tp>
167 constexpr bool __is_unexpected =
false;
168 template<
typename _Tp>
169 constexpr bool __is_unexpected<unexpected<_Tp>> =
true;
171 template<
typename _Fn,
typename _Tp>
172 using __result = remove_cvref_t<invoke_result_t<_Fn&&, _Tp&&>>;
173 template<
typename _Fn,
typename _Tp>
174 using __result_xform = remove_cv_t<invoke_result_t<_Fn&&, _Tp&&>>;
175 template<
typename _Fn>
176 using __result0 = remove_cvref_t<invoke_result_t<_Fn&&>>;
177 template<
typename _Fn>
178 using __result0_xform = remove_cv_t<invoke_result_t<_Fn&&>>;
180 template<
typename _Er>
181 concept __can_be_unexpected
182 = is_object_v<_Er> && (!is_array_v<_Er>)
183 && (!__expected::__is_unexpected<_Er>)
184 && (!is_const_v<_Er>) && (!is_volatile_v<_Er>);
187 struct __in_place_inv { };
188 struct __unexpect_inv { };
192 template<
typename _Er>
195 static_assert( __expected::__can_be_unexpected<_Er> );
201 template<
typename _Err = _Er>
202 requires (!is_same_v<remove_cvref_t<_Err>,
unexpected>)
203 && (!is_same_v<remove_cvref_t<_Err>, in_place_t>)
204 && is_constructible_v<_Er, _Err>
207 noexcept(is_nothrow_constructible_v<_Er, _Err>)
208 : _M_unex(std::
forward<_Err>(__e))
211 template<
typename... _Args>
212 requires is_constructible_v<_Er, _Args...>
215 noexcept(is_nothrow_constructible_v<_Er, _Args...>)
216 : _M_unex(std::
forward<_Args>(__args)...)
219 template<
typename _Up,
typename... _Args>
220 requires is_constructible_v<_Er, initializer_list<_Up>&, _Args...>
222 unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
223 noexcept(is_nothrow_constructible_v<_Er, initializer_list<_Up>&,
225 : _M_unex(__il, std::
forward<_Args>(__args)...)
234 error() const & noexcept {
return _M_unex; }
238 error() &
noexcept {
return _M_unex; }
241 constexpr const _Er&&
242 error() const && noexcept {
return std::move(_M_unex); }
246 error() &&
noexcept {
return std::move(_M_unex); }
249 swap(
unexpected& __other)
noexcept(is_nothrow_swappable_v<_Er>)
250 requires is_swappable_v<_Er>
253 swap(_M_unex, __other._M_unex);
256 template<
typename _Err>
258 friend constexpr bool
260 {
return __x._M_unex == __y.error(); }
262 friend constexpr void
264 requires is_swappable_v<_Er>
276 template<
typename _Tp>
279 static_assert( is_nothrow_move_constructible_v<_Tp> );
283 : _M_guarded(__builtin_addressof(__x)), _M_tmp(std::move(__x))
284 { std::destroy_at(_M_guarded); }
289 if (_M_guarded) [[unlikely]]
290 std::construct_at(_M_guarded,
std::move(_M_tmp));
293 _Guard(
const _Guard&) =
delete;
294 _Guard& operator=(
const _Guard&) =
delete;
299 _M_guarded =
nullptr;
309 template<
typename _Tp,
typename _Up,
typename _Vp>
311 __reinit(_Tp* __newval, _Up* __oldval, _Vp&& __arg)
312 noexcept(is_nothrow_constructible_v<_Tp, _Vp>)
314 if constexpr (is_nothrow_constructible_v<_Tp, _Vp>)
316 std::destroy_at(__oldval);
319 else if constexpr (is_nothrow_move_constructible_v<_Tp>)
322 std::destroy_at(__oldval);
323 std::construct_at(__newval,
std::move(__tmp));
327 _Guard<_Up> __guard(*__oldval);
339 template<
typename _Tp,
typename _Up>
340 concept __not_constructing_bool_from_expected
341 = ! is_same_v<remove_cv_t<_Tp>,
bool>
342 || ! __is_expected<remove_cvref_t<_Up>>;
346 template<
typename _Tp,
typename _Er>
349 static_assert( ! is_reference_v<_Tp> );
350 static_assert( ! is_function_v<_Tp> );
351 static_assert( ! is_same_v<remove_cv_t<_Tp>, in_place_t> );
352 static_assert( ! is_same_v<remove_cv_t<_Tp>, unexpect_t> );
353 static_assert( ! __expected::__is_unexpected<remove_cv_t<_Tp>> );
354 static_assert( __expected::__can_be_unexpected<_Er> );
358 template<
typename _Up,
typename _Gr,
typename _Unex = unexpected<_Er>,
359 typename = remove_cv_t<_Tp>>
360 static constexpr bool __cons_from_expected
361 = __or_v<is_constructible<_Tp, expected<_Up, _Gr>&>,
362 is_constructible<_Tp, expected<_Up, _Gr>>,
363 is_constructible<_Tp, const expected<_Up, _Gr>&>,
364 is_constructible<_Tp, const expected<_Up, _Gr>>,
365 is_convertible<expected<_Up, _Gr>&, _Tp>,
366 is_convertible<expected<_Up, _Gr>, _Tp>,
367 is_convertible<const expected<_Up, _Gr>&, _Tp>,
368 is_convertible<const expected<_Up, _Gr>, _Tp>,
369 is_constructible<_Unex, expected<_Up, _Gr>&>,
370 is_constructible<_Unex, expected<_Up, _Gr>>,
371 is_constructible<_Unex, const expected<_Up, _Gr>&>,
372 is_constructible<_Unex, const expected<_Up, _Gr>>
379 template<
typename _Up,
typename _Gr,
typename _Unex>
380 static constexpr bool __cons_from_expected<_Up, _Gr, _Unex, bool>
381 = __or_v<is_constructible<_Unex, expected<_Up, _Gr>&>,
382 is_constructible<_Unex, expected<_Up, _Gr>>,
383 is_constructible<_Unex, const expected<_Up, _Gr>&>,
384 is_constructible<_Unex, const expected<_Up, _Gr>>
387 template<
typename _Up,
typename _Gr>
388 constexpr static bool __explicit_conv
389 = __or_v<__not_<is_convertible<_Up, _Tp>>,
390 __not_<is_convertible<_Gr, _Er>>
393 template<
typename _Up>
394 static constexpr bool __same_val
395 = is_same_v<typename _Up::value_type, _Tp>;
397 template<
typename _Up>
398 static constexpr bool __same_err
399 = is_same_v<typename _Up::error_type, _Er>;
402 using value_type = _Tp;
404 using unexpected_type = unexpected<_Er>;
406 template<
typename _Up>
407 using rebind = expected<_Up, error_type>;
411 noexcept(is_nothrow_default_constructible_v<_Tp>)
412 requires is_default_constructible_v<_Tp>
413 : _M_val(), _M_has_value(true)
416 expected(
const expected&) =
default;
419 expected(
const expected& __x)
420 noexcept(__and_v<is_nothrow_copy_constructible<_Tp>,
421 is_nothrow_copy_constructible<_Er>>)
422 requires is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Er>
423 && (!is_trivially_copy_constructible_v<_Tp>
424 || !is_trivially_copy_constructible_v<_Er>)
425 : _M_has_value(__x._M_has_value)
428 std::construct_at(__builtin_addressof(_M_val), __x._M_val);
430 std::construct_at(__builtin_addressof(_M_unex), __x._M_unex);
433 expected(expected&&) =
default;
436 expected(expected&& __x)
437 noexcept(__and_v<is_nothrow_move_constructible<_Tp>,
438 is_nothrow_move_constructible<_Er>>)
439 requires is_move_constructible_v<_Tp> && is_move_constructible_v<_Er>
440 && (!is_trivially_move_constructible_v<_Tp>
441 || !is_trivially_move_constructible_v<_Er>)
442 : _M_has_value(__x._M_has_value)
445 std::construct_at(__builtin_addressof(_M_val),
448 std::construct_at(__builtin_addressof(_M_unex),
452 template<
typename _Up,
typename _Gr>
453 requires is_constructible_v<_Tp, const _Up&>
454 && is_constructible_v<_Er, const _Gr&>
455 && (!__cons_from_expected<_Up, _Gr>)
456 constexpr explicit(__explicit_conv<const _Up&, const _Gr&>)
457 expected(
const expected<_Up, _Gr>& __x)
458 noexcept(__and_v<is_nothrow_constructible<_Tp, const _Up&>,
459 is_nothrow_constructible<_Er, const _Gr&>>)
460 : _M_has_value(__x._M_has_value)
463 std::construct_at(__builtin_addressof(_M_val), __x._M_val);
465 std::construct_at(__builtin_addressof(_M_unex), __x._M_unex);
468 template<
typename _Up,
typename _Gr>
469 requires is_constructible_v<_Tp, _Up>
470 && is_constructible_v<_Er, _Gr>
471 && (!__cons_from_expected<_Up, _Gr>)
472 constexpr explicit(__explicit_conv<_Up, _Gr>)
473 expected(expected<_Up, _Gr>&& __x)
474 noexcept(__and_v<is_nothrow_constructible<_Tp, _Up>,
475 is_nothrow_constructible<_Er, _Gr>>)
476 : _M_has_value(__x._M_has_value)
479 std::construct_at(__builtin_addressof(_M_val),
482 std::construct_at(__builtin_addressof(_M_unex),
486 template<
typename _Up = remove_cv_t<_Tp>>
487 requires (!is_same_v<remove_cvref_t<_Up>, expected>)
488 && (!is_same_v<remove_cvref_t<_Up>, in_place_t>)
489 && (!is_same_v<remove_cvref_t<_Up>, unexpect_t>)
490 && is_constructible_v<_Tp, _Up>
491 && (!__expected::__is_unexpected<remove_cvref_t<_Up>>)
492 && __expected::__not_constructing_bool_from_expected<_Tp, _Up>
493 constexpr explicit(!is_convertible_v<_Up, _Tp>)
495 noexcept(is_nothrow_constructible_v<_Tp, _Up>)
496 : _M_val(std::
forward<_Up>(__v)), _M_has_value(true)
499 template<
typename _Gr = _Er>
500 requires is_constructible_v<_Er, const _Gr&>
501 constexpr explicit(!is_convertible_v<const _Gr&, _Er>)
502 expected(
const unexpected<_Gr>& __u)
503 noexcept(is_nothrow_constructible_v<_Er, const _Gr&>)
504 : _M_unex(__u.error()), _M_has_value(false)
507 template<
typename _Gr = _Er>
508 requires is_constructible_v<_Er, _Gr>
509 constexpr explicit(!is_convertible_v<_Gr, _Er>)
510 expected(unexpected<_Gr>&& __u)
511 noexcept(is_nothrow_constructible_v<_Er, _Gr>)
512 : _M_unex(std::move(__u).error()), _M_has_value(false)
515 template<
typename... _Args>
516 requires is_constructible_v<_Tp, _Args...>
518 expected(in_place_t, _Args&&... __args)
519 noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
520 : _M_val(std::
forward<_Args>(__args)...), _M_has_value(true)
523 template<
typename _Up,
typename... _Args>
524 requires is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>
526 expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
527 noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&,
529 : _M_val(__il, std::
forward<_Args>(__args)...), _M_has_value(true)
532 template<
typename... _Args>
533 requires is_constructible_v<_Er, _Args...>
535 expected(unexpect_t, _Args&&... __args)
536 noexcept(is_nothrow_constructible_v<_Er, _Args...>)
537 : _M_unex(std::
forward<_Args>(__args)...), _M_has_value(false)
540 template<
typename _Up,
typename... _Args>
541 requires is_constructible_v<_Er, initializer_list<_Up>&, _Args...>
543 expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
544 noexcept(is_nothrow_constructible_v<_Er, initializer_list<_Up>&,
546 : _M_unex(__il, std::
forward<_Args>(__args)...), _M_has_value(false)
549 constexpr ~expected() =
default;
551 constexpr ~expected()
552 requires (!is_trivially_destructible_v<_Tp>)
553 || (!is_trivially_destructible_v<_Er>)
556 std::destroy_at(__builtin_addressof(_M_val));
558 std::destroy_at(__builtin_addressof(_M_unex));
563 expected& operator=(
const expected&) =
delete;
566 operator=(
const expected& __x)
567 noexcept(__and_v<is_nothrow_copy_constructible<_Tp>,
568 is_nothrow_copy_constructible<_Er>,
569 is_nothrow_copy_assignable<_Tp>,
570 is_nothrow_copy_assignable<_Er>>)
571 requires is_copy_assignable_v<_Tp> && is_copy_constructible_v<_Tp>
572 && is_copy_assignable_v<_Er> && is_copy_constructible_v<_Er>
573 && (is_nothrow_move_constructible_v<_Tp>
574 || is_nothrow_move_constructible_v<_Er>)
576 if (__x._M_has_value)
577 this->_M_assign_val(__x._M_val);
579 this->_M_assign_unex(__x._M_unex);
584 operator=(expected&& __x)
585 noexcept(__and_v<is_nothrow_move_constructible<_Tp>,
586 is_nothrow_move_constructible<_Er>,
587 is_nothrow_move_assignable<_Tp>,
588 is_nothrow_move_assignable<_Er>>)
589 requires is_move_assignable_v<_Tp> && is_move_constructible_v<_Tp>
590 && is_move_assignable_v<_Er> && is_move_constructible_v<_Er>
591 && (is_nothrow_move_constructible_v<_Tp>
592 || is_nothrow_move_constructible_v<_Er>)
594 if (__x._M_has_value)
601 template<
typename _Up = remove_cv_t<_Tp>>
602 requires (!is_same_v<expected, remove_cvref_t<_Up>>)
603 && (!__expected::__is_unexpected<remove_cvref_t<_Up>>)
604 && is_constructible_v<_Tp, _Up> && is_assignable_v<_Tp&, _Up>
605 && (is_nothrow_constructible_v<_Tp, _Up>
606 || is_nothrow_move_constructible_v<_Tp>
607 || is_nothrow_move_constructible_v<_Er>)
615 template<
typename _Gr>
616 requires is_constructible_v<_Er, const _Gr&>
617 && is_assignable_v<_Er&, const _Gr&>
618 && (is_nothrow_constructible_v<_Er, const _Gr&>
619 || is_nothrow_move_constructible_v<_Tp>
620 || is_nothrow_move_constructible_v<_Er>)
622 operator=(
const unexpected<_Gr>& __e)
624 _M_assign_unex(__e.error());
628 template<
typename _Gr>
629 requires is_constructible_v<_Er, _Gr>
630 && is_assignable_v<_Er&, _Gr>
631 && (is_nothrow_constructible_v<_Er, _Gr>
632 || is_nothrow_move_constructible_v<_Tp>
633 || is_nothrow_move_constructible_v<_Er>)
635 operator=(unexpected<_Gr>&& __e)
643 template<
typename... _Args>
644 requires is_nothrow_constructible_v<_Tp, _Args...>
646 emplace(_Args&&... __args)
noexcept
649 std::destroy_at(__builtin_addressof(_M_val));
652 std::destroy_at(__builtin_addressof(_M_unex));
655 std::construct_at(__builtin_addressof(_M_val),
660 template<
typename _Up,
typename... _Args>
661 requires is_nothrow_constructible_v<_Tp, initializer_list<_Up>&,
664 emplace(initializer_list<_Up> __il, _Args&&... __args)
noexcept
667 std::destroy_at(__builtin_addressof(_M_val));
670 std::destroy_at(__builtin_addressof(_M_unex));
673 std::construct_at(__builtin_addressof(_M_val),
681 noexcept(__and_v<is_nothrow_move_constructible<_Tp>,
682 is_nothrow_move_constructible<_Er>,
683 is_nothrow_swappable<_Tp&>,
684 is_nothrow_swappable<_Er&>>)
685 requires is_swappable_v<_Tp> && is_swappable_v<_Er>
686 && is_move_constructible_v<_Tp>
687 && is_move_constructible_v<_Er>
688 && (is_nothrow_move_constructible_v<_Tp>
689 || is_nothrow_move_constructible_v<_Er>)
693 if (__x._M_has_value)
696 swap(_M_val, __x._M_val);
699 this->_M_swap_val_unex(__x);
703 if (__x._M_has_value)
704 __x._M_swap_val_unex(*
this);
708 swap(_M_unex, __x._M_unex);
717 operator->() const noexcept
719 __glibcxx_assert(_M_has_value);
720 return __builtin_addressof(_M_val);
725 operator->() noexcept
727 __glibcxx_assert(_M_has_value);
728 return __builtin_addressof(_M_val);
735 __glibcxx_assert(_M_has_value);
743 __glibcxx_assert(_M_has_value);
748 constexpr const _Tp&&
751 __glibcxx_assert(_M_has_value);
759 __glibcxx_assert(_M_has_value);
765 operator bool() const noexcept {
return _M_has_value; }
768 constexpr bool has_value() const noexcept {
return _M_has_value; }
773 static_assert( is_copy_constructible_v<_Er> );
774 if (_M_has_value) [[likely]]
776 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(_M_unex));
782 static_assert( is_copy_constructible_v<_Er> );
783 if (_M_has_value) [[likely]]
785 const auto& __unex = _M_unex;
786 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(__unex));
789 constexpr const _Tp&&
792 static_assert( is_copy_constructible_v<_Er> );
793 static_assert( is_constructible_v<_Er, const _Er&&> );
794 if (_M_has_value) [[likely]]
796 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(
std::move(_M_unex)));
802 static_assert( is_copy_constructible_v<_Er> );
803 static_assert( is_constructible_v<_Er, _Er&&> );
804 if (_M_has_value) [[likely]]
806 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(
std::move(_M_unex)));
810 error() const & noexcept
812 __glibcxx_assert(!_M_has_value);
819 __glibcxx_assert(!_M_has_value);
823 constexpr const _Er&&
824 error() const && noexcept
826 __glibcxx_assert(!_M_has_value);
833 __glibcxx_assert(!_M_has_value);
839 template<
typename _Up = remove_cv_t<_Tp>>
840 constexpr remove_cv_t<_Tp>
841 value_or(_Up&& __v)
const &
842 noexcept(__and_v<is_nothrow_copy_constructible<_Tp>,
843 is_nothrow_convertible<_Up, _Tp>>)
845 using _Xp = remove_cv_t<_Tp>;
846 static_assert( is_convertible_v<const _Tp&, _Xp> );
847 static_assert( is_convertible_v<_Up, _Tp> );
854 template<
typename _Up = remove_cv_t<_Tp>>
855 constexpr remove_cv_t<_Tp>
856 value_or(_Up&& __v) &&
857 noexcept(__and_v<is_nothrow_move_constructible<_Tp>,
858 is_nothrow_convertible<_Up, _Tp>>)
860 using _Xp = remove_cv_t<_Tp>;
861 static_assert( is_convertible_v<_Tp, _Xp> );
862 static_assert( is_convertible_v<_Up, _Xp> );
869 template<
typename _Gr = _Er>
871 error_or(_Gr&& __e)
const&
873 static_assert( is_copy_constructible_v<_Er> );
874 static_assert( is_convertible_v<_Gr, _Er> );
881 template<
typename _Gr = _Er>
883 error_or(_Gr&& __e) &&
885 static_assert( is_move_constructible_v<_Er> );
886 static_assert( is_convertible_v<_Gr, _Er> );
895 template<
typename _Fn>
requires is_constructible_v<_Er, _Er&>
897 and_then(_Fn&& __f) &
899 using _Up = __expected::__result<_Fn, _Tp&>;
900 static_assert(__expected::__is_expected<_Up>,
901 "the function passed to std::expected<T, E>::and_then "
902 "must return a std::expected");
903 static_assert(is_same_v<typename _Up::error_type, _Er>,
904 "the function passed to std::expected<T, E>::and_then "
905 "must return a std::expected with the same error_type");
910 return _Up(unexpect, _M_unex);
913 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er&>
915 and_then(_Fn&& __f)
const &
917 using _Up = __expected::__result<_Fn, const _Tp&>;
918 static_assert(__expected::__is_expected<_Up>,
919 "the function passed to std::expected<T, E>::and_then "
920 "must return a std::expected");
921 static_assert(is_same_v<typename _Up::error_type, _Er>,
922 "the function passed to std::expected<T, E>::and_then "
923 "must return a std::expected with the same error_type");
928 return _Up(unexpect, _M_unex);
931 template<
typename _Fn>
requires is_constructible_v<_Er, _Er>
933 and_then(_Fn&& __f) &&
935 using _Up = __expected::__result<_Fn, _Tp&&>;
936 static_assert(__expected::__is_expected<_Up>,
937 "the function passed to std::expected<T, E>::and_then "
938 "must return a std::expected");
939 static_assert(is_same_v<typename _Up::error_type, _Er>,
940 "the function passed to std::expected<T, E>::and_then "
941 "must return a std::expected with the same error_type");
946 return _Up(unexpect,
std::move(_M_unex));
950 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er>
952 and_then(_Fn&& __f)
const &&
954 using _Up = __expected::__result<_Fn, const _Tp&&>;
955 static_assert(__expected::__is_expected<_Up>,
956 "the function passed to std::expected<T, E>::and_then "
957 "must return a std::expected");
958 static_assert(is_same_v<typename _Up::error_type, _Er>,
959 "the function passed to std::expected<T, E>::and_then "
960 "must return a std::expected with the same error_type");
965 return _Up(unexpect,
std::move(_M_unex));
968 template<
typename _Fn>
requires is_constructible_v<_Tp, _Tp&>
972 using _Gr = __expected::__result<_Fn, _Er&>;
973 static_assert(__expected::__is_expected<_Gr>,
974 "the function passed to std::expected<T, E>::or_else "
975 "must return a std::expected");
976 static_assert(is_same_v<typename _Gr::value_type, _Tp>,
977 "the function passed to std::expected<T, E>::or_else "
978 "must return a std::expected with the same value_type");
981 return _Gr(in_place, _M_val);
986 template<
typename _Fn>
requires is_constructible_v<_Tp, const _Tp&>
988 or_else(_Fn&& __f)
const &
990 using _Gr = __expected::__result<_Fn, const _Er&>;
991 static_assert(__expected::__is_expected<_Gr>,
992 "the function passed to std::expected<T, E>::or_else "
993 "must return a std::expected");
994 static_assert(is_same_v<typename _Gr::value_type, _Tp>,
995 "the function passed to std::expected<T, E>::or_else "
996 "must return a std::expected with the same value_type");
999 return _Gr(in_place, _M_val);
1005 template<
typename _Fn>
requires is_constructible_v<_Tp, _Tp>
1007 or_else(_Fn&& __f) &&
1009 using _Gr = __expected::__result<_Fn, _Er&&>;
1010 static_assert(__expected::__is_expected<_Gr>,
1011 "the function passed to std::expected<T, E>::or_else "
1012 "must return a std::expected");
1013 static_assert(is_same_v<typename _Gr::value_type, _Tp>,
1014 "the function passed to std::expected<T, E>::or_else "
1015 "must return a std::expected with the same value_type");
1018 return _Gr(in_place,
std::move(_M_val));
1023 template<
typename _Fn>
requires is_constructible_v<_Tp, const _Tp>
1025 or_else(_Fn&& __f)
const &&
1027 using _Gr = __expected::__result<_Fn, const _Er&&>;
1028 static_assert(__expected::__is_expected<_Gr>,
1029 "the function passed to std::expected<T, E>::or_else "
1030 "must return a std::expected");
1031 static_assert(is_same_v<typename _Gr::value_type, _Tp>,
1032 "the function passed to std::expected<T, E>::or_else "
1033 "must return a std::expected with the same value_type");
1036 return _Gr(in_place,
std::move(_M_val));
1041 template<
typename _Fn>
requires is_constructible_v<_Er, _Er&>
1043 transform(_Fn&& __f) &
1045 using _Up = __expected::__result_xform<_Fn, _Tp&>;
1046 using _Res = expected<_Up, _Er>;
1049 return _Res(__in_place_inv{}, [&]() {
1054 return _Res(unexpect, _M_unex);
1057 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er&>
1059 transform(_Fn&& __f)
const &
1061 using _Up = __expected::__result_xform<_Fn, const _Tp&>;
1062 using _Res = expected<_Up, _Er>;
1065 return _Res(__in_place_inv{}, [&]() {
1070 return _Res(unexpect, _M_unex);
1073 template<
typename _Fn>
requires is_constructible_v<_Er, _Er>
1075 transform(_Fn&& __f) &&
1077 using _Up = __expected::__result_xform<_Fn, _Tp>;
1078 using _Res = expected<_Up, _Er>;
1081 return _Res(__in_place_inv{}, [&]() {
1086 return _Res(unexpect,
std::move(_M_unex));
1089 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er>
1091 transform(_Fn&& __f)
const &&
1093 using _Up = __expected::__result_xform<_Fn, const _Tp>;
1094 using _Res = expected<_Up, _Er>;
1097 return _Res(__in_place_inv{}, [&]() {
1102 return _Res(unexpect,
std::move(_M_unex));
1105 template<
typename _Fn>
requires is_constructible_v<_Tp, _Tp&>
1107 transform_error(_Fn&& __f) &
1109 using _Gr = __expected::__result_xform<_Fn, _Er&>;
1110 using _Res = expected<_Tp, _Gr>;
1113 return _Res(in_place, _M_val);
1115 return _Res(__unexpect_inv{}, [&]() {
1121 template<
typename _Fn>
requires is_constructible_v<_Tp, const _Tp&>
1123 transform_error(_Fn&& __f)
const &
1125 using _Gr = __expected::__result_xform<_Fn, const _Er&>;
1126 using _Res = expected<_Tp, _Gr>;
1129 return _Res(in_place, _M_val);
1131 return _Res(__unexpect_inv{}, [&]() {
1137 template<
typename _Fn>
requires is_constructible_v<_Tp, _Tp>
1139 transform_error(_Fn&& __f) &&
1141 using _Gr = __expected::__result_xform<_Fn, _Er&&>;
1142 using _Res = expected<_Tp, _Gr>;
1145 return _Res(in_place,
std::move(_M_val));
1147 return _Res(__unexpect_inv{}, [&]() {
1153 template<
typename _Fn>
requires is_constructible_v<_Tp, const _Tp>
1155 transform_error(_Fn&& __f)
const &&
1157 using _Gr = __expected::__result_xform<_Fn, const _Er&&>;
1158 using _Res = expected<_Tp, _Gr>;
1161 return _Res(in_place,
std::move(_M_val));
1163 return _Res(__unexpect_inv{}, [&]() {
1171 template<
typename _Up,
typename _Er2>
1172 requires (!is_void_v<_Up>)
1173 &&
requires (
const _Tp& __t,
const _Up& __u,
1174 const _Er& __e,
const _Er2& __e2) {
1175 { __t == __u } -> convertible_to<bool>;
1176 { __e == __e2 } -> convertible_to<bool>;
1179 friend constexpr bool
1180 operator==(
const expected& __x,
const expected<_Up, _Er2>& __y)
1181 noexcept(
noexcept(bool(*__x == *__y))
1182 &&
noexcept(bool(__x.error() == __y.error())))
1184 if (__x.has_value() != __y.has_value())
1186 if (__x.has_value())
1187 return *__x == *__y;
1188 return __x.error() == __y.error();
1191 template<
typename _Up, same_as<_Tp> _Vp>
1192 requires (!__expected::__is_expected<_Up>)
1193 &&
requires (
const _Tp& __t,
const _Up& __u) {
1194 { __t == __u } -> convertible_to<bool>;
1197 friend constexpr bool
1198 operator==(
const expected<_Vp, _Er>& __x,
const _Up& __v)
1199 noexcept(
noexcept(bool(*__x == __v)))
1201 if (__x.has_value())
1206 template<
typename _Er2>
1207 requires requires (
const _Er& __e,
const _Er2& __e2) {
1208 { __e == __e2 } -> convertible_to<bool>;
1211 friend constexpr bool
1212 operator==(
const expected& __x,
const unexpected<_Er2>& __e)
1213 noexcept(
noexcept(bool(__x.error() == __e.error())))
1215 if (!__x.has_value())
1216 return __x.error() == __e.error();
1220 friend constexpr void
1221 swap(expected& __x, expected& __y)
1222 noexcept(
noexcept(__x.swap(__y)))
1223 requires requires {__x.swap(__y);}
1227 template<
typename,
typename>
friend class expected;
1229 template<
typename _Vp>
1231 _M_assign_val(_Vp&& __v)
1237 __expected::__reinit(__builtin_addressof(_M_val),
1238 __builtin_addressof(_M_unex),
1240 _M_has_value =
true;
1244 template<
typename _Vp>
1246 _M_assign_unex(_Vp&& __v)
1250 __expected::__reinit(__builtin_addressof(_M_unex),
1251 __builtin_addressof(_M_val),
1253 _M_has_value =
false;
1262 _M_swap_val_unex(expected& __rhs)
1263 noexcept(__and_v<is_nothrow_move_constructible<_Er>,
1264 is_nothrow_move_constructible<_Tp>>)
1266 if constexpr (is_nothrow_move_constructible_v<_Er>)
1268 __expected::_Guard<_Er> __guard(__rhs._M_unex);
1269 std::construct_at(__builtin_addressof(__rhs._M_val),
1271 __rhs._M_has_value =
true;
1272 std::destroy_at(__builtin_addressof(_M_val));
1273 std::construct_at(__builtin_addressof(_M_unex),
1275 _M_has_value =
false;
1279 __expected::_Guard<_Tp> __guard(_M_val);
1280 std::construct_at(__builtin_addressof(_M_unex),
1282 _M_has_value =
false;
1283 std::destroy_at(__builtin_addressof(__rhs._M_unex));
1284 std::construct_at(__builtin_addressof(__rhs._M_val),
1286 __rhs._M_has_value =
true;
1290 using __in_place_inv = __expected::__in_place_inv;
1291 using __unexpect_inv = __expected::__unexpect_inv;
1293 template<
typename _Fn>
1295 expected(__in_place_inv, _Fn&& __fn)
1296 : _M_val(std::
forward<_Fn>(__fn)()), _M_has_value(true)
1299 template<
typename _Fn>
1301 expected(__unexpect_inv, _Fn&& __fn)
1302 : _M_unex(std::
forward<_Fn>(__fn)()), _M_has_value(false)
1306 remove_cv_t<_Tp> _M_val;
1314 template<
typename _Tp,
typename _Er>
requires is_void_v<_Tp>
1315 class expected<_Tp, _Er>
1317 static_assert( __expected::__can_be_unexpected<_Er> );
1319 template<
typename _Up,
typename _Err,
typename _Unex = unexpected<_Er>>
1320 static constexpr bool __cons_from_expected
1321 = __or_v<is_constructible<_Unex, expected<_Up, _Err>&>,
1322 is_constructible<_Unex, expected<_Up, _Err>>,
1323 is_constructible<_Unex, const expected<_Up, _Err>&>,
1324 is_constructible<_Unex, const expected<_Up, _Err>>
1327 template<
typename _Up>
1328 static constexpr bool __same_val
1329 = is_same_v<typename _Up::value_type, _Tp>;
1331 template<
typename _Up>
1332 static constexpr bool __same_err
1333 = is_same_v<typename _Up::error_type, _Er>;
1336 using value_type = _Tp;
1338 using unexpected_type = unexpected<_Er>;
1340 template<
typename _Up>
1341 using rebind = expected<_Up, error_type>;
1345 : _M_void(), _M_has_value(true)
1348 expected(
const expected&) =
default;
1351 expected(
const expected& __x)
1352 noexcept(is_nothrow_copy_constructible_v<_Er>)
1353 requires is_copy_constructible_v<_Er>
1354 && (!is_trivially_copy_constructible_v<_Er>)
1355 : _M_void(), _M_has_value(__x._M_has_value)
1358 std::construct_at(__builtin_addressof(_M_unex), __x._M_unex);
1361 expected(expected&&) =
default;
1364 expected(expected&& __x)
1365 noexcept(is_nothrow_move_constructible_v<_Er>)
1366 requires is_move_constructible_v<_Er>
1367 && (!is_trivially_move_constructible_v<_Er>)
1368 : _M_void(), _M_has_value(__x._M_has_value)
1371 std::construct_at(__builtin_addressof(_M_unex),
1375 template<
typename _Up,
typename _Gr>
1376 requires is_void_v<_Up>
1377 && is_constructible_v<_Er, const _Gr&>
1378 && (!__cons_from_expected<_Up, _Gr>)
1379 constexpr explicit(!is_convertible_v<const _Gr&, _Er>)
1380 expected(
const expected<_Up, _Gr>& __x)
1381 noexcept(is_nothrow_constructible_v<_Er, const _Gr&>)
1382 : _M_void(), _M_has_value(__x._M_has_value)
1385 std::construct_at(__builtin_addressof(_M_unex), __x._M_unex);
1388 template<
typename _Up,
typename _Gr>
1389 requires is_void_v<_Up>
1390 && is_constructible_v<_Er, _Gr>
1391 && (!__cons_from_expected<_Up, _Gr>)
1392 constexpr explicit(!is_convertible_v<_Gr, _Er>)
1393 expected(expected<_Up, _Gr>&& __x)
1394 noexcept(is_nothrow_constructible_v<_Er, _Gr>)
1395 : _M_void(), _M_has_value(__x._M_has_value)
1398 std::construct_at(__builtin_addressof(_M_unex),
1402 template<
typename _Gr = _Er>
1403 requires is_constructible_v<_Er, const _Gr&>
1404 constexpr explicit(!is_convertible_v<const _Gr&, _Er>)
1405 expected(
const unexpected<_Gr>& __u)
1406 noexcept(is_nothrow_constructible_v<_Er, const _Gr&>)
1407 : _M_unex(__u.error()), _M_has_value(false)
1410 template<
typename _Gr = _Er>
1411 requires is_constructible_v<_Er, _Gr>
1412 constexpr explicit(!is_convertible_v<_Gr, _Er>)
1413 expected(unexpected<_Gr>&& __u)
1414 noexcept(is_nothrow_constructible_v<_Er, _Gr>)
1415 : _M_unex(std::move(__u).error()), _M_has_value(false)
1419 expected(in_place_t) noexcept
1423 template<
typename... _Args>
1424 requires is_constructible_v<_Er, _Args...>
1426 expected(unexpect_t, _Args&&... __args)
1427 noexcept(is_nothrow_constructible_v<_Er, _Args...>)
1428 : _M_unex(std::
forward<_Args>(__args)...), _M_has_value(false)
1431 template<
typename _Up,
typename... _Args>
1432 requires is_constructible_v<_Er, initializer_list<_Up>&, _Args...>
1434 expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
1435 noexcept(is_nothrow_constructible_v<_Er, initializer_list<_Up>&,
1437 : _M_unex(__il, std::
forward<_Args>(__args)...), _M_has_value(false)
1440 constexpr ~expected() =
default;
1442 constexpr ~expected()
requires (!is_trivially_destructible_v<_Er>)
1445 std::destroy_at(__builtin_addressof(_M_unex));
1450 expected& operator=(
const expected&) =
delete;
1453 operator=(
const expected& __x)
1454 noexcept(__and_v<is_nothrow_copy_constructible<_Er>,
1455 is_nothrow_copy_assignable<_Er>>)
1456 requires is_copy_constructible_v<_Er>
1457 && is_copy_assignable_v<_Er>
1459 if (__x._M_has_value)
1462 _M_assign_unex(__x._M_unex);
1467 operator=(expected&& __x)
1468 noexcept(__and_v<is_nothrow_move_constructible<_Er>,
1469 is_nothrow_move_assignable<_Er>>)
1470 requires is_move_constructible_v<_Er>
1471 && is_move_assignable_v<_Er>
1473 if (__x._M_has_value)
1480 template<
typename _Gr>
1481 requires is_constructible_v<_Er, const _Gr&>
1482 && is_assignable_v<_Er&, const _Gr&>
1484 operator=(
const unexpected<_Gr>& __e)
1486 _M_assign_unex(__e.error());
1490 template<
typename _Gr>
1491 requires is_constructible_v<_Er, _Gr>
1492 && is_assignable_v<_Er&, _Gr>
1494 operator=(unexpected<_Gr>&& __e)
1507 std::destroy_at(__builtin_addressof(_M_unex));
1508 _M_has_value =
true;
1515 noexcept(__and_v<is_nothrow_swappable<_Er&>,
1516 is_nothrow_move_constructible<_Er>>)
1517 requires is_swappable_v<_Er> && is_move_constructible_v<_Er>
1521 if (!__x._M_has_value)
1523 std::construct_at(__builtin_addressof(_M_unex),
1525 std::destroy_at(__builtin_addressof(__x._M_unex));
1526 _M_has_value =
false;
1527 __x._M_has_value =
true;
1532 if (__x._M_has_value)
1534 std::construct_at(__builtin_addressof(__x._M_unex),
1536 std::destroy_at(__builtin_addressof(_M_unex));
1537 _M_has_value =
true;
1538 __x._M_has_value =
false;
1543 swap(_M_unex, __x._M_unex);
1552 operator bool() const noexcept {
return _M_has_value; }
1555 constexpr bool has_value() const noexcept {
return _M_has_value; }
1558 operator*() const noexcept { __glibcxx_assert(_M_has_value); }
1563 static_assert( is_copy_constructible_v<_Er> );
1564 if (_M_has_value) [[likely]]
1566 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(_M_unex));
1572 static_assert( is_copy_constructible_v<_Er> );
1573 static_assert( is_move_constructible_v<_Er> );
1574 if (_M_has_value) [[likely]]
1576 _GLIBCXX_THROW_OR_ABORT(bad_expected_access<_Er>(
std::move(_M_unex)));
1579 constexpr const _Er&
1580 error() const & noexcept
1582 __glibcxx_assert(!_M_has_value);
1589 __glibcxx_assert(!_M_has_value);
1593 constexpr const _Er&&
1594 error() const && noexcept
1596 __glibcxx_assert(!_M_has_value);
1603 __glibcxx_assert(!_M_has_value);
1607 template<
typename _Gr = _Er>
1609 error_or(_Gr&& __e)
const&
1611 static_assert( is_copy_constructible_v<_Er> );
1612 static_assert( is_convertible_v<_Gr, _Er> );
1619 template<
typename _Gr = _Er>
1621 error_or(_Gr&& __e) &&
1623 static_assert( is_move_constructible_v<_Er> );
1624 static_assert( is_convertible_v<_Gr, _Er> );
1633 template<
typename _Fn>
requires is_constructible_v<_Er, _Er&>
1635 and_then(_Fn&& __f) &
1637 using _Up = __expected::__result0<_Fn>;
1638 static_assert(__expected::__is_expected<_Up>);
1639 static_assert(is_same_v<typename _Up::error_type, _Er>);
1644 return _Up(unexpect, _M_unex);
1647 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er&>
1649 and_then(_Fn&& __f)
const &
1651 using _Up = __expected::__result0<_Fn>;
1652 static_assert(__expected::__is_expected<_Up>);
1653 static_assert(is_same_v<typename _Up::error_type, _Er>);
1658 return _Up(unexpect, _M_unex);
1661 template<
typename _Fn>
requires is_constructible_v<_Er, _Er>
1663 and_then(_Fn&& __f) &&
1665 using _Up = __expected::__result0<_Fn>;
1666 static_assert(__expected::__is_expected<_Up>);
1667 static_assert(is_same_v<typename _Up::error_type, _Er>);
1672 return _Up(unexpect,
std::move(_M_unex));
1675 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er>
1677 and_then(_Fn&& __f)
const &&
1679 using _Up = __expected::__result0<_Fn>;
1680 static_assert(__expected::__is_expected<_Up>);
1681 static_assert(is_same_v<typename _Up::error_type, _Er>);
1686 return _Up(unexpect,
std::move(_M_unex));
1689 template<
typename _Fn>
1691 or_else(_Fn&& __f) &
1693 using _Gr = __expected::__result<_Fn, _Er&>;
1694 static_assert(__expected::__is_expected<_Gr>);
1695 static_assert(is_same_v<typename _Gr::value_type, _Tp>);
1703 template<
typename _Fn>
1705 or_else(_Fn&& __f)
const &
1707 using _Gr = __expected::__result<_Fn, const _Er&>;
1708 static_assert(__expected::__is_expected<_Gr>);
1709 static_assert(is_same_v<typename _Gr::value_type, _Tp>);
1717 template<
typename _Fn>
1719 or_else(_Fn&& __f) &&
1721 using _Gr = __expected::__result<_Fn, _Er&&>;
1722 static_assert(__expected::__is_expected<_Gr>);
1723 static_assert(is_same_v<typename _Gr::value_type, _Tp>);
1731 template<
typename _Fn>
1733 or_else(_Fn&& __f)
const &&
1735 using _Gr = __expected::__result<_Fn, const _Er&&>;
1736 static_assert(__expected::__is_expected<_Gr>);
1737 static_assert(is_same_v<typename _Gr::value_type, _Tp>);
1745 template<
typename _Fn>
requires is_constructible_v<_Er, _Er&>
1747 transform(_Fn&& __f) &
1749 using _Up = __expected::__result0_xform<_Fn>;
1750 using _Res = expected<_Up, _Er>;
1755 return _Res(unexpect, _M_unex);
1758 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er&>
1760 transform(_Fn&& __f)
const &
1762 using _Up = __expected::__result0_xform<_Fn>;
1763 using _Res = expected<_Up, _Er>;
1768 return _Res(unexpect, _M_unex);
1771 template<
typename _Fn>
requires is_constructible_v<_Er, _Er>
1773 transform(_Fn&& __f) &&
1775 using _Up = __expected::__result0_xform<_Fn>;
1776 using _Res = expected<_Up, _Er>;
1781 return _Res(unexpect,
std::move(_M_unex));
1784 template<
typename _Fn>
requires is_constructible_v<_Er, const _Er>
1786 transform(_Fn&& __f)
const &&
1788 using _Up = __expected::__result0_xform<_Fn>;
1789 using _Res = expected<_Up, _Er>;
1794 return _Res(unexpect,
std::move(_M_unex));
1797 template<
typename _Fn>
1799 transform_error(_Fn&& __f) &
1801 using _Gr = __expected::__result_xform<_Fn, _Er&>;
1802 using _Res = expected<_Tp, _Gr>;
1807 return _Res(__unexpect_inv{}, [&]() {
1813 template<
typename _Fn>
1815 transform_error(_Fn&& __f)
const &
1817 using _Gr = __expected::__result_xform<_Fn, const _Er&>;
1818 using _Res = expected<_Tp, _Gr>;
1823 return _Res(__unexpect_inv{}, [&]() {
1829 template<
typename _Fn>
1831 transform_error(_Fn&& __f) &&
1833 using _Gr = __expected::__result_xform<_Fn, _Er&&>;
1834 using _Res = expected<_Tp, _Gr>;
1839 return _Res(__unexpect_inv{}, [&]() {
1845 template<
typename _Fn>
1847 transform_error(_Fn&& __f)
const &&
1849 using _Gr = __expected::__result_xform<_Fn, const _Er&&>;
1850 using _Res = expected<_Tp, _Gr>;
1855 return _Res(__unexpect_inv{}, [&]() {
1863 template<
typename _Up,
typename _Er2>
1864 requires is_void_v<_Up>
1865 &&
requires (
const _Er& __e,
const _Er2& __e2) {
1866 { __e == __e2 } -> convertible_to<bool>;
1869 friend constexpr bool
1870 operator==(
const expected& __x,
const expected<_Up, _Er2>& __y)
1871 noexcept(
noexcept(bool(__x.error() == __y.error())))
1873 if (__x.has_value() != __y.has_value())
1875 if (__x.has_value())
1877 return __x.error() == __y.error();
1880 template<
typename _Er2>
1881 requires requires (
const _Er& __e,
const _Er2& __e2) {
1882 { __e == __e2 } -> convertible_to<bool>;
1885 friend constexpr bool
1886 operator==(
const expected& __x,
const unexpected<_Er2>& __e)
1887 noexcept(
noexcept(bool(__x.error() == __e.error())))
1889 if (!__x.has_value())
1890 return __x.error() == __e.error();
1894 friend constexpr void
1895 swap(expected& __x, expected& __y)
1896 noexcept(
noexcept(__x.swap(__y)))
1897 requires requires { __x.swap(__y); }
1901 template<
typename,
typename>
friend class expected;
1903 template<
typename _Vp>
1905 _M_assign_unex(_Vp&& __v)
1909 std::construct_at(__builtin_addressof(_M_unex),
1911 _M_has_value =
false;
1917 using __in_place_inv = __expected::__in_place_inv;
1918 using __unexpect_inv = __expected::__unexpect_inv;
1920 template<
typename _Fn>
1922 expected(__in_place_inv, _Fn&& __fn)
1923 : _M_void(), _M_has_value(true)
1926 template<
typename _Fn>
1928 expected(__unexpect_inv, _Fn&& __fn)
1929 : _M_unex(std::
forward<_Fn>(__fn)()), _M_has_value(false)
1941_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
Base class for all library exceptions.