55
55
#include < cuda/std/detail/libcxx/include/__type_traits/negation.h>
56
56
#include < cuda/std/detail/libcxx/include/__type_traits/remove_cv.h>
57
57
#include < cuda/std/detail/libcxx/include/__type_traits/remove_cvref.h>
58
+ #include < cuda/std/detail/libcxx/include/__utility/as_const.h>
58
59
#include < cuda/std/detail/libcxx/include/__utility/exception_guard.h>
59
60
#include < cuda/std/detail/libcxx/include/__utility/forward.h>
60
61
#include < cuda/std/detail/libcxx/include/__utility/in_place.h>
@@ -551,6 +552,8 @@ class expected
551
552
552
553
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp& value () const &
553
554
{
555
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
556
+ " expected::value() const& requires is_copy_constructible_v<E>" );
554
557
if (!this ->__has_val_ )
555
558
{
556
559
__throw_bad_expected_access<_Err>(this ->__union_ .__unex_ );
@@ -560,15 +563,21 @@ class expected
560
563
561
564
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp& value () &
562
565
{
566
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
567
+ " expected::value() & requires is_copy_constructible_v<E>" );
563
568
if (!this ->__has_val_ )
564
569
{
565
- __throw_bad_expected_access<_Err>(this ->__union_ .__unex_ );
570
+ __throw_bad_expected_access<_Err>(_CUDA_VSTD::as_const ( this ->__union_ .__unex_ ) );
566
571
}
567
572
return this ->__union_ .__val_ ;
568
573
}
569
574
570
575
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp&& value() const &&
571
576
{
577
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
578
+ " expected::value() const&& requires is_copy_constructible_v<E>" );
579
+ static_assert (_LIBCUDACXX_TRAIT (is_constructible, _Err, decltype (_CUDA_VSTD::move (error ()))),
580
+ " expected::value() const&& requires is_constructible_v<E, decltype(_CUDA_VSTD::move(error()))>" );
572
581
if (!this ->__has_val_ )
573
582
{
574
583
__throw_bad_expected_access<_Err>(_CUDA_VSTD::move (this ->__union_ .__unex_ ));
@@ -578,6 +587,10 @@ class expected
578
587
579
588
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp&& value() &&
580
589
{
590
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
591
+ " expected::value() const&& requires is_copy_constructible_v<E>" );
592
+ static_assert (_LIBCUDACXX_TRAIT (is_constructible, _Err, decltype (_CUDA_VSTD::move (error ()))),
593
+ " expected::value() const&& requires is_constructible_v<E, decltype(_CUDA_VSTD::move(error()))>" );
581
594
if (!this ->__has_val_ )
582
595
{
583
596
__throw_bad_expected_access<_Err>(_CUDA_VSTD::move (this ->__union_ .__unex_ ));
@@ -1473,6 +1486,8 @@ class expected<void, _Err>
1473
1486
1474
1487
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr void value () const &
1475
1488
{
1489
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
1490
+ " expected::value() const& requires is_copy_constructible_v<E>" );
1476
1491
if (!this ->__has_val_ )
1477
1492
{
1478
1493
__throw_bad_expected_access<_Err>(this ->__union_ .__unex_ );
@@ -1481,6 +1496,10 @@ class expected<void, _Err>
1481
1496
1482
1497
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr void value () &&
1483
1498
{
1499
+ static_assert (_LIBCUDACXX_TRAIT (is_copy_constructible, _Err),
1500
+ " expected::value() && requires is_copy_constructible_v<E>" );
1501
+ static_assert (_LIBCUDACXX_TRAIT (is_move_constructible, _Err),
1502
+ " expected::value() && requires is_move_constructible_v<E>" );
1484
1503
if (!this ->__has_val_ )
1485
1504
{
1486
1505
__throw_bad_expected_access<_Err>(_CUDA_VSTD::move (this ->__union_ .__unex_ ));
0 commit comments