codekingpro/portable-devtools
114k
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.7//8//===----------------------------------------------------------------------===//9#ifndef _LIBCUDACXX___EXPECTED_EXPECTED_H10#define _LIBCUDACXX___EXPECTED_EXPECTED_H11 12#ifndef __cuda_std__13#include <__config>14#endif // __cuda_std__15 16#include "../__assert"17#include "../__concepts/invocable.h"18#ifndef _LIBCUDACXX_NO_EXCEPTIONS19#include "../__expected/bad_expected_access.h"20#endif // _LIBCUDACXX_NO_EXCEPTIONS21#include "../__expected/expected_base.h"22#include "../__expected/unexpect.h"23#include "../__expected/unexpected.h"24#include "../__memory/addressof.h"25#include "../__memory/construct_at.h"26#include "../__type_traits/conjunction.h"27#include "../__type_traits/disjunction.h"28#include "../__type_traits/is_assignable.h"29#include "../__type_traits/is_constructible.h"30#include "../__type_traits/is_convertible.h"31#include "../__type_traits/is_copy_assignable.h"32#include "../__type_traits/is_copy_constructible.h"33#include "../__type_traits/is_default_constructible.h"34#include "../__type_traits/is_function.h"35#include "../__type_traits/is_move_assignable.h"36#include "../__type_traits/is_move_constructible.h"37#include "../__type_traits/is_nothrow_constructible.h"38#include "../__type_traits/is_nothrow_copy_assignable.h"39#include "../__type_traits/is_nothrow_copy_constructible.h"40#include "../__type_traits/is_nothrow_default_constructible.h"41#include "../__type_traits/is_nothrow_move_assignable.h"42#include "../__type_traits/is_nothrow_move_constructible.h"43#include "../__type_traits/is_reference.h"44#include "../__type_traits/is_same.h"45#include "../__type_traits/is_swappable.h"46#include "../__type_traits/is_trivially_copy_constructible.h"47#include "../__type_traits/is_trivially_destructible.h"48#include "../__type_traits/is_trivially_move_constructible.h"49#include "../__type_traits/is_void.h"50#include "../__type_traits/lazy.h"51#include "../__type_traits/negation.h"52#include "../__type_traits/remove_cv.h"53#include "../__type_traits/remove_cvref.h"54#include "../__utility/exception_guard.h"55#include "../__utility/forward.h"56#include "../__utility/in_place.h"57#include "../__utility/move.h"58#include "../__utility/swap.h"59 60#include "../cstdlib"61#include "../initializer_list"62 63#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)64# pragma GCC system_header65#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)66# pragma clang system_header67#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)68# pragma system_header69#endif // no system header70 71#if _LIBCUDACXX_STD_VER > 1172 73_LIBCUDACXX_BEGIN_NAMESPACE_STD74 75template <class _Tp, class _Err>76class expected;77 78namespace __expected {79 80 template <class _Err, class _Arg>81 _LIBCUDACXX_INLINE_VISIBILITY82 void __throw_bad_expected_access(_Arg&& __arg) {83#ifndef _LIBCUDACXX_NO_EXCEPTIONS84 throw _CUDA_STD::bad_expected_access<_Err>(_CUDA_VSTD::forward<_Arg>(__arg));85#else86 (void)__arg;87 _LIBCUDACXX_UNREACHABLE();88#endif // _LIBCUDACXX_NO_EXCEPTIONS89 }90 91 template <class _Tp, class _Err>92 _LIBCUDACXX_INLINE_VAR constexpr bool __valid_expected =93 !_LIBCUDACXX_TRAIT(is_reference, _Tp) &&94 !_LIBCUDACXX_TRAIT(is_function, _Tp) &&95 !_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<_Tp>, in_place_t) &&96 !_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<_Tp>, unexpect_t) &&97 !__unexpected::__is_unexpected<__remove_cv_t<_Tp>> &&98 __unexpected::__valid_unexpected<_Err>;99 100 template <class _Tp>101 _LIBCUDACXX_INLINE_VAR constexpr bool __is_expected = false;102 103 template <class _Tp, class _Err>104 _LIBCUDACXX_INLINE_VAR constexpr bool __is_expected<expected<_Tp, _Err>> = true;105 106 template <class _Tp>107 _LIBCUDACXX_INLINE_VAR constexpr bool __is_expected_nonvoid = __is_expected<_Tp>;108 109 template <class _Err>110 _LIBCUDACXX_INLINE_VAR constexpr bool __is_expected_nonvoid<expected<void, _Err>> = false;111 112 template<class _Tp, class _Err>113 _LIBCUDACXX_INLINE_VAR constexpr bool __can_swap =114 _LIBCUDACXX_TRAIT(is_swappable, _Tp)115 && _LIBCUDACXX_TRAIT(is_swappable, _Err)116 && _LIBCUDACXX_TRAIT(is_move_constructible, _Tp)117 && _LIBCUDACXX_TRAIT(is_move_constructible, _Err)118 && (_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp)119 || _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err));120 121 template<class _Err>122 _LIBCUDACXX_INLINE_VAR constexpr bool __can_swap<void, _Err> =123 _LIBCUDACXX_TRAIT(is_swappable, _Err)124 && _LIBCUDACXX_TRAIT(is_move_constructible, _Err);125} // namespace __expected126 127template <class _Tp, class _Err>128class expected : private __expected_move_assign<_Tp, _Err>129 , private __expected_sfinae_ctor_base_t<_Tp, _Err>130 , private __expected_sfinae_assign_base_t<_Tp, _Err>131{132 using __base = __expected_move_assign<_Tp, _Err>;133 134 static_assert(__expected::__valid_expected<_Tp, _Err>,135 "[expected.object.general] A program that instantiates the definition of template expected<T, E> for a "136 "reference type, a function type, or for possibly cv-qualified types in_place_t, unexpect_t, or a "137 "specialization of unexpected for the T parameter is ill-formed. A program that instantiates the "138 "definition of the template expected<T, E> with a type for the E parameter that is not a valid "139 "template argument for unexpected is ill-formed.");140 141 template <class, class>142 friend class expected;143 144public:145 using value_type = _Tp;146 using error_type = _Err;147 using unexpected_type = unexpected<_Err>;148 149 template <class _Up>150 using rebind = expected<_Up, error_type>;151 152 // [expected.object.ctor], constructors153 _LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)154 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_default_constructible, _Tp2))155 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr156 expected() noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Tp2))157 : __base(true)158 {}159 160 constexpr expected(const expected&) = default;161 constexpr expected(expected&&) = default;162 constexpr expected& operator=(const expected&) = default;163 constexpr expected& operator=(expected&&) = default;164 165private:166 template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>167 using __can_convert =168 _And< is_constructible<_Tp, _UfQual>,169 is_constructible<_Err, _OtherErrQual>,170 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,171 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,172 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,173 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,174 _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,175 _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,176 _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,177 _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>,178 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,179 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,180 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,181 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;182 183 184public:185 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)186 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value _LIBCUDACXX_AND187 _LIBCUDACXX_TRAIT(is_convertible, const _Up&, _Tp) _LIBCUDACXX_AND188 _LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)189 )190 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17191 expected(const expected<_Up, _OtherErr>& __other)192 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, const _Up&) &&193 _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened194 : __base(__other.__has_val_)195 {196 if (__other.__has_val_) {197 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __other.__union_.__val_);198 } else {199 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);200 }201 }202 203 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)204 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value _LIBCUDACXX_AND205 (!_LIBCUDACXX_TRAIT(is_convertible, const _Up&, _Tp) || !_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))206 )207 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17208 explicit expected(const expected<_Up, _OtherErr>& __other)209 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, const _Up&) &&210 _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened211 : __base(__other.__has_val_)212 {213 if (__other.__has_val_) {214 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __other.__union_.__val_);215 } else {216 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);217 }218 }219 220 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)221 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCUDACXX_AND222 _LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp) _LIBCUDACXX_AND223 _LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)224 )225 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17226 expected(expected<_Up, _OtherErr>&& __other)227 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) &&228 _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened229 : __base(__other.__has_val_)230 {231 if (__other.__has_val_) {232 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__val_));233 } else {234 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));235 }236 }237 238 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)239 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCUDACXX_AND240 (!_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp) || !_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))241 )242 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17243 explicit expected(expected<_Up, _OtherErr>&& __other)244 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) &&245 _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened246 : __base(__other.__has_val_)247 {248 if (__other.__has_val_) {249 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__val_));250 } else {251 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));252 }253 }254 255 _LIBCUDACXX_TEMPLATE(class _Up = _Tp)256 _LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, __remove_cvref_t<_Up>, in_place_t)) _LIBCUDACXX_AND257 (!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND258 (!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND259 _LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND260 _LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp)261 )262 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr263 expected(_Up&& __u) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up)) // strengthened264 : __base(in_place, _CUDA_VSTD::forward<_Up>(__u))265 {}266 267 _LIBCUDACXX_TEMPLATE(class _Up = _Tp)268 _LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, __remove_cvref_t<_Up>, in_place_t)) _LIBCUDACXX_AND269 (!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND270 (!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND271 _LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND272 (!_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp))273 )274 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr275 explicit expected(_Up&& __u) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up)) // strengthened276 : __base(in_place, _CUDA_VSTD::forward<_Up>(__u))277 {}278 279 _LIBCUDACXX_TEMPLATE(class _OtherErr)280 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND281 _LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)282 )283 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr284 expected(const unexpected<_OtherErr>& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened285 : __base(unexpect, __unex.error())286 {}287 288 _LIBCUDACXX_TEMPLATE(class _OtherErr)289 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND290 (!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))291 )292 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr293 explicit expected(const unexpected<_OtherErr>& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened294 : __base(unexpect, __unex.error())295 {}296 297 _LIBCUDACXX_TEMPLATE(class _OtherErr)298 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND299 _LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)300 )301 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr302 expected(unexpected<_OtherErr>&& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened303 : __base(unexpect, _CUDA_VSTD::move(__unex.error()))304 {}305 306 307 _LIBCUDACXX_TEMPLATE(class _OtherErr)308 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND309 (!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))310 )311 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr312 explicit expected(unexpected<_OtherErr>&& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened313 : __base(unexpect, _CUDA_VSTD::move(__unex.error()))314 {}315 316 _LIBCUDACXX_TEMPLATE(class... _Args)317 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp, _Args...))318 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr319 explicit expected(in_place_t, _Args&&... __args) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...)) // strengthened320 : __base(in_place, _CUDA_VSTD::forward<_Args>(__args)...)321 {}322 323 _LIBCUDACXX_TEMPLATE(class _Up, class... _Args)324 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp, initializer_list<_Up>&, _Args...))325 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr326 explicit expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)327 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, initializer_list<_Up>&, _Args...)) // strengthened328 : __base(in_place, __il, _CUDA_VSTD::forward<_Args>(__args)...)329 {}330 331 _LIBCUDACXX_TEMPLATE(class... _Args)332 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _Args...))333 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr334 explicit expected(unexpect_t, _Args&&... __args) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...)) // strengthened335 : __base(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)336 {}337 338 _LIBCUDACXX_TEMPLATE(class _Up, class... _Args)339 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, initializer_list<_Up>&, _Args...))340 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr341 explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)342 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, initializer_list<_Up>&, _Args...)) // strengthened343 : __base(unexpect, __il, _CUDA_VSTD::forward<_Args>(__args)...)344 {}345 346private:347 template<class _Fun, class... _Args>348 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr349 expected(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)350 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))351 : __base(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)352 {}353 354 template<class _Fun, class... _Args>355 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr356 expected(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)357 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))358 : __base(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)359 {}360 361public:362 // [expected.object.assign], assignment363 _LIBCUDACXX_TEMPLATE(class _Up = _Tp)364 _LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND365 (!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND366 _LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND367 _LIBCUDACXX_TRAIT(is_assignable, _Tp&, _Up) _LIBCUDACXX_AND368 (_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) ||369 _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) ||370 _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err))371 )372 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17373 expected& operator=(_Up&& __v) {374 if (this->__has_val_) {375 this->__union_.__val_ = _CUDA_VSTD::forward<_Up>(__v);376 } else {377 this->__reinit_expected(this->__union_.__val_, this->__union_.__unex_, _CUDA_VSTD::forward<_Up>(__v));378 this->__has_val_ = true;379 }380 return *this;381 }382 383private:384 template <class _OtherErrQual>385 static constexpr bool __can_assign_from_unexpected =386 _And< is_constructible<_Err, _OtherErrQual>,387 is_assignable<_Err&, _OtherErrQual>,388 _Lazy<_Or,389 is_nothrow_constructible<_Err, _OtherErrQual>,390 is_nothrow_move_constructible<_Tp>,391 is_nothrow_move_constructible<_Err>> >::value;392 393public:394 _LIBCUDACXX_TEMPLATE(class _OtherErr)395 _LIBCUDACXX_REQUIRES( __can_assign_from_unexpected<const _OtherErr&>)396 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17397 expected& operator=(const unexpected<_OtherErr>& __un) {398 if (this->__has_val_) {399 this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, __un.error());400 this->__has_val_ = false;401 } else {402 this->__union_.__unex_ = __un.error();403 }404 return *this;405 }406 407 _LIBCUDACXX_TEMPLATE(class _OtherErr)408 _LIBCUDACXX_REQUIRES( __can_assign_from_unexpected<_OtherErr>)409 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17410 expected& operator=(unexpected<_OtherErr>&& __un) {411 if (this->__has_val_) {412 this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, _CUDA_VSTD::move(__un.error()));413 this->__has_val_ = false;414 } else {415 this->__union_.__unex_ = _CUDA_VSTD::move(__un.error());416 }417 return *this;418 }419 420 _LIBCUDACXX_TEMPLATE(class... _Args)421 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))422 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17423 _Tp& emplace(_Args&&... __args) noexcept {424 if (this->__has_val_) {425 _CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__val_));426 } else {427 _CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));428 this->__has_val_ = true;429 }430 return *_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::forward<_Args>(__args)...);431 }432 433 _LIBCUDACXX_TEMPLATE(class _Up, class... _Args)434 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, initializer_list<_Up>&, _Args...))435 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17436 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept {437 if (this->__has_val_) {438 _CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__val_));439 } else {440 _CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));441 this->__has_val_ = true;442 }443 return *_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __il, _CUDA_VSTD::forward<_Args>(__args)...);444 }445 446 447public:448 // [expected.object.swap], swap449 _LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp, class _Err2 = _Err)450 _LIBCUDACXX_REQUIRES( __expected::__can_swap<_Tp2, _Err2>)451 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17452 void swap(expected<_Tp2, _Err>& __rhs)453 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp2) &&454 _LIBCUDACXX_TRAIT(is_nothrow_swappable, _Tp2) &&455 _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err) &&456 _LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err))457 {458 if (this->__has_val_) {459 if (__rhs.__has_val_) {460 using _CUDA_VSTD::swap;461 swap(this->__union_.__val_, __rhs.__union_.__val_);462 } else {463 this->__swap_val_unex_impl(*this, __rhs);464 }465 } else {466 if (__rhs.__has_val_) {467 this->__swap_val_unex_impl(__rhs, *this);468 } else {469 using _CUDA_VSTD::swap;470 swap(this->__union_.__unex_, __rhs.__union_.__unex_);471 }472 }473 }474 475 template<class _Tp2 = _Tp, class _Err2 = _Err>476 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17477 auto swap(expected& __x, expected& __y) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp2) &&478 _LIBCUDACXX_TRAIT(is_nothrow_swappable, _Tp2) &&479 _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2) &&480 _LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err2))481 _LIBCUDACXX_TRAILING_REQUIRES(void)(__expected::__can_swap<_Tp2, _Err2>)482 {483 return __x.swap(__y); // some compiler warn about non void function without return484 }485 486 // [expected.object.obs], observers487 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp* operator->() const noexcept {488 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator-> requires the expected to contain a value");489 return _CUDA_VSTD::addressof(this->__union_.__val_);490 }491 492 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp* operator->() noexcept {493 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator-> requires the expected to contain a value");494 return _CUDA_VSTD::addressof(this->__union_.__val_);495 }496 497 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp& operator*() const& noexcept {498 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");499 return this->__union_.__val_;500 }501 502 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp& operator*() & noexcept {503 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");504 return this->__union_.__val_;505 }506 507 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp&& operator*() const&& noexcept {508 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");509 return _CUDA_VSTD::move(this->__union_.__val_);510 }511 512 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp&& operator*() && noexcept {513 _LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");514 return _CUDA_VSTD::move(this->__union_.__val_);515 }516 517 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr explicit operator bool() const noexcept { return this->__has_val_; }518 519 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr bool has_value() const noexcept { return this->__has_val_; }520 521 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp& value() const& {522 if (!this->__has_val_) {523 __expected::__throw_bad_expected_access<_Err>(this->__union_.__unex_);524 }525 return this->__union_.__val_;526 }527 528 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr529 _Tp& value() & {530 if (!this->__has_val_) {531 __expected::__throw_bad_expected_access<_Err>(this->__union_.__unex_);532 }533 return this->__union_.__val_;534 }535 536 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr537 const _Tp&& value() const&& {538 if (!this->__has_val_) {539 __expected::__throw_bad_expected_access<_Err>(_CUDA_VSTD::move(this->__union_.__unex_));540 }541 return _CUDA_VSTD::move(this->__union_.__val_);542 }543 544 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr545 _Tp&& value() && {546 if (!this->__has_val_) {547 __expected::__throw_bad_expected_access<_Err>(_CUDA_VSTD::move(this->__union_.__unex_));548 }549 return _CUDA_VSTD::move(this->__union_.__val_);550 }551 552 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr553 const _Err& error() const& noexcept {554 _LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");555 return this->__union_.__unex_;556 }557 558 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr559 _Err& error() & noexcept {560 _LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");561 return this->__union_.__unex_;562 }563 564 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr565 const _Err&& error() const&& noexcept {566 _LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");567 return _CUDA_VSTD::move(this->__union_.__unex_);568 }569 570 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr571 _Err&& error() && noexcept {572 _LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");573 return _CUDA_VSTD::move(this->__union_.__unex_);574 }575 576 template <class _Up>577 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr578 _Tp value_or(_Up&& __v) const& {579 static_assert(_LIBCUDACXX_TRAIT(is_copy_constructible, _Tp), "value_type has to be copy constructible");580 static_assert(_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp), "argument has to be convertible to value_type");581 return this->__has_val_ ? this->__union_.__val_ : static_cast<_Tp>(_CUDA_VSTD::forward<_Up>(__v));582 }583 584 template <class _Up>585 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr586 _Tp value_or(_Up&& __v) && {587 static_assert(_LIBCUDACXX_TRAIT(is_move_constructible, _Tp), "value_type has to be move constructible");588 static_assert(_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp), "argument has to be convertible to value_type");589 return this->__has_val_ ? _CUDA_VSTD::move(this->__union_.__val_) : static_cast<_Tp>(_CUDA_VSTD::forward<_Up>(__v));590 }591 592 // [expected.object.monadic]593 _LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)594 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&))595 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr596 auto and_then(_Fun&& __fun) & {597 using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Tp&>>;598 599 static_assert(__expected::__is_expected<_Res>,600 "Result of f(value()) must be a specialization of std::expected");601 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),602 "The error type of the result of f(value()) must be the same as that of std::expected");603 604 if (this->__has_val_) {605 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);606 } else {607 return _Res{unexpect, this->__union_.__unex_};608 }609 }610 611 _LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)612 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2))613 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr614 auto and_then(_Fun&& __fun) const& {615 using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Tp&>>;616 617 static_assert(__expected::__is_expected<_Res>,618 "Result of f(value()) must be a specialization of std::expected");619 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),620 "The error type of the result of f(value()) must be the same as that of std::expected");621 622 if (this->__has_val_) {623 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);624 } else {625 return _Res{unexpect, this->__union_.__unex_};626 }627 }628 629 _LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)630 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2))631 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr632 auto and_then(_Fun&& __fun) && {633 using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Tp>>;634 635 static_assert(__expected::__is_expected<_Res>,636 "Result of f(value()) must be a specialization of std::expected");637 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),638 "The error type of the result of f(value()) must be the same as that of std::expected");639 640 if (this->__has_val_) {641 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));642 } else {643 return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};644 }645 }646 647 _LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)648 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2))649 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr650 auto and_then(_Fun&& __fun) const&& {651 using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Tp>>;652 653 static_assert(__expected::__is_expected<_Res>,654 "Result of f(value()) must be a specialization of std::expected");655 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),656 "The error type of the result of f(value()) must be the same as that of std::expected");657 658 if (this->__has_val_) {659 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));660 } else {661 return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};662 }663 }664 665 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)666 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, _Tp2&))667 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr668 auto or_else(_Fun&& __fun) & {669 using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err&>>;670 671 static_assert(__expected::__is_expected<_Res>,672 "Result of std::expected::or_else must be a specialization of std::expected");673 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),674 "The value type of the result of std::expected::or_else must be the same as that of std::expected");675 676 if (this->__has_val_) {677 return _Res{in_place, this->__union_.__val_};678 } else {679 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);680 }681 }682 683 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)684 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Tp2))685 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr686 auto or_else(_Fun&& __fun) const& {687 using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err&>>;688 689 static_assert(__expected::__is_expected<_Res>,690 "Result of std::expected::or_else must be a specialization of std::expected");691 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),692 "The value type of the result of std::expected::or_else must be the same as that of std::expected");693 694 if (this->__has_val_) {695 return _Res{in_place, this->__union_.__val_};696 } else {697 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);698 }699 }700 701 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)702 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Tp2))703 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr704 auto or_else(_Fun&& __fun) && {705 using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err>>;706 707 static_assert(__expected::__is_expected<_Res>,708 "Result of std::expected::or_else must be a specialization of std::expected");709 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),710 "The value type of the result of std::expected::or_else must be the same as that of std::expected");711 712 if (this->__has_val_) {713 return _Res{in_place, _CUDA_VSTD::move(this->__union_.__val_)};714 } else {715 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));716 }717 }718 719 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)720 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, const _Tp2))721 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr722 auto or_else(_Fun&& __fun) const&& {723 using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err>>;724 725 static_assert(__expected::__is_expected<_Res>,726 "Result of std::expected::or_else must be a specialization of std::expected");727 static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),728 "The value type of the result of std::expected::or_else must be the same as that of std::expected");729 730 if (this->__has_val_) {731 return _Res{in_place, _CUDA_VSTD::move(this->__union_.__val_)};732 } else {733 return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));734 }735 }736 737 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)738 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND739 _LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2&>>, void))740 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr741 auto transform(_Fun&& __fun) & {742 static_assert(invocable<_Fun, _Tp&>,743 "std::expected::transform requires that F must be invocable with T.");744 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp&>>;745 746 if (this->__has_val_) {747 _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);748 return expected<void, _Err>{};749 } else {750 return expected<_Res, _Err>{unexpect, this->__union_.__unex_};751 }752 }753 754 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)755 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND756 (!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2&>>, void)))757 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr758 auto transform(_Fun&& __fun) & {759 static_assert(invocable<_Fun, _Tp&>,760 "std::expected::transform requires that F must be invocable with T.");761 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp&>>;762 763 static_assert(__invoke_constructible<_Fun, _Tp&>,764 "std::expected::transform requires that the return type of F is constructible with the result of invoking F");765 static_assert(__expected::__valid_expected<_Res, _Err>,766 "std::expected::transform requires that the return type of F must be a valid argument for std::expected");767 768 if (this->__has_val_) {769 return expected<_Res, _Err>{770 __expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_};771 } else {772 return expected<_Res, _Err>{unexpect, this->__union_.__unex_};773 }774 }775 776 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)777 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND778 _LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2&>>, void))779 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr780 auto transform(_Fun&& __fun) const& {781 static_assert(invocable<_Fun, const _Tp&>,782 "std::expected::transform requires that F must be invocable with T.");783 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp&>>;784 785 if (this->__has_val_) {786 _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);787 return expected<_Res, _Err>{};788 } else {789 return expected<_Res, _Err>{unexpect, this->__union_.__unex_};790 }791 }792 793 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)794 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND795 (!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2&>>, void)))796 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr797 auto transform(_Fun&& __fun) const& {798 static_assert(invocable<_Fun, const _Tp&>,799 "std::expected::transform requires that F must be invocable with T");800 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp&>>;801 802 static_assert(__invoke_constructible<_Fun, const _Tp&>,803 "std::expected::transform requires that the return type of F is constructible with the result of invoking F");804 static_assert(__expected::__valid_expected<_Res, _Err>,805 "std::expected::transform requires that the return type of F must be a valid argument for std::expected");806 807 if (this->__has_val_) {808 return expected<_Res, _Err>{809 __expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_};810 } else {811 return expected<_Res, _Err>{unexpect, this->__union_.__unex_};812 }813 }814 815 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)816 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND817 _LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2>>, void))818 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr819 auto transform(_Fun&& __fun) && {820 static_assert(invocable<_Fun, _Tp>,821 "std::expected::transform requires that F must be invocable with T.");822 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp>>;823 824 if (this->__has_val_) {825 _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));826 return expected<_Res, _Err>{};827 } else {828 return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};829 }830 }831 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)832 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND833 (!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2>>, void)))834 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr835 auto transform(_Fun&& __fun) && {836 static_assert(invocable<_Fun, _Tp>,837 "std::expected::transform requires that F must be invocable with T");838 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp>>;839 840 static_assert(__invoke_constructible<_Fun, _Tp>,841 "std::expected::transform requires that the return type of F is constructible with the result of invoking F");842 static_assert(__expected::__valid_expected<_Res, _Err>,843 "std::expected::transform requires that the return type of F must be a valid argument for std::expected");844 845 if (this->__has_val_) {846 return expected<_Res, _Err>{847 __expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_)};848 } else {849 return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};850 }851 }852 853 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)854 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND855 _LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2>>, void))856 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr857 auto transform(_Fun&& __fun) const&& {858 static_assert(invocable<_Fun, const _Tp>,859 "std::expected::transform requires that F must be invocable with T.");860 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp>>;861 862 if (this->__has_val_) {863 _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));864 return expected<_Res, _Err>{};865 } else {866 return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};867 }868 }869 870 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)871 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND872 (!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2>>, void)))873 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr874 auto transform(_Fun&& __fun) const&& {875 static_assert(invocable<_Fun, const _Tp>,876 "std::expected::transform requires that F must be invocable with T");877 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp>>;878 879 static_assert(__invoke_constructible<_Fun, const _Tp>,880 "std::expected::transform requires that the return type of F is constructible with the result of invoking F");881 static_assert(__expected::__valid_expected<_Res, _Err>,882 "std::expected::transform requires that the return type of F must be a valid argument for std::expected");883 884 if (this->__has_val_) {885 return expected<_Res, _Err>{886 __expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_)};887 } else {888 return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};889 }890 }891 892 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)893 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, _Tp2&))894 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr895 auto transform_error(_Fun&& __fun) & {896 static_assert(invocable<_Fun, _Err&>,897 "std::expected::transform_error requires that F must be invocable with E");898 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err&>>;899 900 static_assert(__invoke_constructible<_Fun, _Err&>,901 "std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");902 static_assert(__expected::__valid_expected<_Tp, _Res>,903 "std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");904 905 if (this->__has_val_) {906 return expected<_Tp, _Res>{in_place, this->__union_.__val_};907 } else {908 return expected<_Tp, _Res>{909 __expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};910 }911 }912 913 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)914 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Tp2))915 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr916 auto transform_error(_Fun&& __fun) const& {917 static_assert(invocable<_Fun, const _Err&>,918 "std::expected::transform_error requires that F must be invocable with E");919 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err&>>;920 921 static_assert(__invoke_constructible<_Fun, const _Err&>,922 "std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");923 static_assert(__expected::__valid_expected<_Tp, _Res>,924 "std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");925 926 if (this->__has_val_) {927 return expected<_Tp, _Res>{in_place, this->__union_.__val_};928 } else {929 return expected<_Tp, _Res>{930 __expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};931 }932 }933 934 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)935 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Tp2))936 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr937 auto transform_error(_Fun&& __fun) && {938 static_assert(invocable<_Fun, _Err>,939 "std::expected::transform_error requires that F must be invocable with E");940 using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err>>;941 942 static_assert(__invoke_constructible<_Fun, _Err>,943 "std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");944 static_assert(__expected::__valid_expected<_Tp, _Res>,945 "std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");946 947 if (this->__has_val_) {948 return expected<_Tp, _Res>{in_place, _CUDA_VSTD::move(this->__union_.__val_)};949 } else {950 return expected<_Tp, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),951 _CUDA_VSTD::move(this->__union_.__unex_)};952 }953 }954 955 _LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)956 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, const _Tp2))957 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr958 auto transform_error(_Fun&& __fun) const&& {959 static_assert(invocable<_Fun, const _Err>,960 "std::expected::transform_error requires that F must be invocable with E");961 using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err>>;962 963 static_assert(__invoke_constructible<_Fun, const _Err>,964 "std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");965 static_assert(__expected::__valid_expected<_Tp, _Res>,966 "std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");967 968 if (this->__has_val_) {969 return expected<_Tp, _Res>{in_place, _CUDA_VSTD::move(this->__union_.__val_)};970 } else {971 return expected<_Tp, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),972 _CUDA_VSTD::move(this->__union_.__unex_)};973 }974 }975 976 // [expected.object.eq], equality operators977 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr978 bool operator==(const expected& __x, const expected& __y) {979 if (__x.__has_val_ != __y.has_value()) {980 return false;981 } else {982 if (__x.__has_val_) {983 return __x.__union_.__val_ == __y.value();984 } else {985 return __x.__union_.__unex_ == __y.error();986 }987 }988 }989 990#if _LIBCUDACXX_STD_VER < 20991 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr992 bool operator!=(const expected& __x, const expected& __y) {993 return !(__x == __y);994 }995#endif // _LIBCUDACXX_STD_VER < 20996 997 _LIBCUDACXX_TEMPLATE(class _T2, class _E2)998 _LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_void, _T2)))999 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1000 bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {1001 if (__x.__has_val_ != __y.has_value()) {1002 return false;1003 } else {1004 if (__x.__has_val_) {1005 return __x.__union_.__val_ == __y.value();1006 } else {1007 return __x.__union_.__unex_ == __y.error();1008 }1009 }1010 }1011 1012#if _LIBCUDACXX_STD_VER < 201013 _LIBCUDACXX_TEMPLATE(class _T2, class _E2)1014 _LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_void, _T2)))1015 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1016 bool operator!=(const expected& __x, const expected<_T2, _E2>& __y) {1017 return !(__x == __y);1018 }1019#endif // _LIBCUDACXX_STD_VER < 201020 1021 _LIBCUDACXX_TEMPLATE(class _T2)1022 _LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))1023 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1024 bool operator==(const expected& __x, const _T2& __v) {1025 return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);1026 }1027#if _LIBCUDACXX_STD_VER < 201028 _LIBCUDACXX_TEMPLATE(class _T2)1029 _LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))1030 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1031 bool operator==(const _T2& __v, const expected& __x) {1032 return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);1033 }1034 _LIBCUDACXX_TEMPLATE(class _T2)1035 _LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))1036 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1037 bool operator!=(const expected& __x, const _T2& __v) {1038 return !__x.__has_val_ || static_cast<bool>(__x.__union_.__val_ != __v);1039 }1040 _LIBCUDACXX_TEMPLATE(class _T2)1041 _LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))1042 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1043 bool operator!=(const _T2& __v, const expected& __x) {1044 return !__x.__has_val_ || static_cast<bool>(__x.__union_.__val_ != __v);1045 }1046#endif // _LIBCUDACXX_STD_VER < 201047 1048 template <class _E2>1049 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1050 bool operator==(const expected& __x, const unexpected<_E2>& __e) {1051 return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());1052 }1053#if _LIBCUDACXX_STD_VER < 201054 template <class _E2>1055 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1056 bool operator==(const unexpected<_E2>& __e, const expected& __x) {1057 return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());1058 }1059 template <class _E2>1060 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1061 bool operator!=(const expected& __x, const unexpected<_E2>& __e) {1062 return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __e.error());1063 }1064 template <class _E2>1065 friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1066 bool operator!=(const unexpected<_E2>& __e, const expected& __x) {1067 return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __e.error());1068 }1069#endif // _LIBCUDACXX_STD_VER < 201070};1071 1072 1073template <class _Err>1074class expected<void, _Err> : private __expected_move_assign<void, _Err>1075 , private __expected_void_sfinae_ctor_base_t<_Err>1076 , private __expected_void_sfinae_assign_base_t<_Err>1077{1078 using __base = __expected_move_assign<void, _Err>;1079 static_assert(__unexpected::__valid_unexpected<_Err>,1080 "[expected.void.general] A program that instantiates expected<T, E> with a E that is not a "1081 "valid argument for unexpected<E> is ill-formed");1082 1083 template <class, class>1084 friend class expected;1085 1086 template <class _Up, class _OtherErr, class _OtherErrQual>1087 using __can_convert =1088 _And< is_void<_Up>,1089 is_constructible<_Err, _OtherErrQual>,1090 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,1091 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,1092 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,1093 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;1094 1095public:1096 using value_type = void;1097 using error_type = _Err;1098 using unexpected_type = unexpected<_Err>;1099 1100 template <class _Up>1101 using rebind = expected<_Up, error_type>;1102 1103 // [expected.void.ctor], constructors1104 constexpr expected() = default;1105 constexpr expected(const expected&) = default;1106 constexpr expected(expected&&) = default;1107 constexpr expected& operator=(const expected&) = default;1108 constexpr expected& operator=(expected&&) = default;1109 1110 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)1111 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCUDACXX_AND1112 _LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)1113 )1114 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX171115 expected(const expected<_Up, _OtherErr>& __other)1116 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened1117 : __base(__other.__has_val_)1118 {1119 if (!__other.__has_val_) {1120 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);1121 }1122 }1123 1124 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)1125 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCUDACXX_AND1126 (!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))1127 )1128 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX171129 explicit expected(const expected<_Up, _OtherErr>& __other)1130 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened1131 : __base(__other.__has_val_)1132 {1133 if (!__other.__has_val_) {1134 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);1135 }1136 }1137 1138 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)1139 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCUDACXX_AND1140 _LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)1141 )1142 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX171143 expected(expected<_Up, _OtherErr>&& __other)1144 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened1145 : __base(__other.__has_val_)1146 {1147 if (!__other.__has_val_) {1148 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));1149 }1150 }1151 1152 _LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)1153 _LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCUDACXX_AND1154 (!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))1155 )1156 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX171157 explicit expected(expected<_Up, _OtherErr>&& __other)1158 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened1159 : __base(__other.__has_val_)1160 {1161 if (!__other.__has_val_) {1162 _LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));1163 }1164 }1165 1166 _LIBCUDACXX_TEMPLATE(class _OtherErr)1167 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND1168 _LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)1169 )1170 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1171 expected(const unexpected<_OtherErr>& __unex)1172 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened1173 : __base(unexpect, __unex.error())1174 {}1175 1176 _LIBCUDACXX_TEMPLATE(class _OtherErr)1177 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND1178 (!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))1179 )1180 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1181 explicit expected(const unexpected<_OtherErr>& __unex)1182 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened1183 : __base(unexpect, __unex.error())1184 {}1185 1186 _LIBCUDACXX_TEMPLATE(class _OtherErr)1187 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND1188 _LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))1189 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1190 expected(unexpected<_OtherErr>&& __unex)1191 noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened1192 : __base(unexpect, _CUDA_VSTD::move(__unex.error()))1193 {}1194 1195 _LIBCUDACXX_TEMPLATE(class _OtherErr)1196 _LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND1197 (!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))1198 )1199 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr1200 explicit expected(unexpected<_OtherErr>&& __unex)