10
10
#define _LIBCPP___EXPECTED_EXPECTED_H
11
11
12
12
#include < __assert>
13
- #include < __concepts/boolean_testable .h>
13
+ #include < __concepts/core_convertible_to .h>
14
14
#include < __config>
15
15
#include < __expected/bad_expected_access.h>
16
16
#include < __expected/unexpect.h>
@@ -1141,10 +1141,13 @@ class expected : private __expected_base<_Tp, _Err> {
1141
1141
// [expected.object.eq], equality operators
1142
1142
template <class _T2 , class _E2 >
1143
1143
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(const expected& __x, const expected<_T2, _E2>& __y)
1144
- requires (!is_void_v<_T2>) && requires {
1145
- { *__x == *__y } -> __boolean_testable;
1146
- { __x.error () == __y.error () } -> __boolean_testable;
1147
- }
1144
+ requires (!is_void_v<_T2>)
1145
+ # if _LIBCPP_STD_VER >= 26
1146
+ && requires {
1147
+ { *__x == *__y } -> __core_convertible_to<bool >;
1148
+ { __x.error () == __y.error () } -> __core_convertible_to<bool >;
1149
+ }
1150
+ # endif
1148
1151
{
1149
1152
if (__x.__has_val () != __y.__has_val ()) {
1150
1153
return false ;
@@ -1159,18 +1162,22 @@ class expected : private __expected_base<_Tp, _Err> {
1159
1162
1160
1163
template <class _T2 >
1161
1164
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(const expected& __x, const _T2& __v)
1165
+ # if _LIBCPP_STD_VER >= 26
1162
1166
requires (!__is_std_expected<_T2>::value) && requires {
1163
- { *__x == __v } -> __boolean_testable ;
1167
+ { *__x == __v } -> __core_convertible_to< bool > ;
1164
1168
}
1169
+ # endif
1165
1170
{
1166
1171
return __x.__has_val () && static_cast <bool >(__x.__val () == __v);
1167
1172
}
1168
1173
1169
1174
template <class _E2 >
1170
1175
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(const expected& __x, const unexpected<_E2>& __e)
1176
+ # if _LIBCPP_STD_VER >= 26
1171
1177
requires requires {
1172
- { __x.error () == __e.error () } -> __boolean_testable ;
1178
+ { __x.error () == __e.error () } -> __core_convertible_to< bool > ;
1173
1179
}
1180
+ # endif
1174
1181
{
1175
1182
return !__x.__has_val () && static_cast <bool >(__x.__unex () == __e.error ());
1176
1183
}
@@ -1865,9 +1872,12 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
1865
1872
template <class _T2 , class _E2 >
1866
1873
requires is_void_v<_T2>
1867
1874
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(const expected& __x, const expected<_T2, _E2>& __y)
1875
+ # if _LIBCPP_STD_VER >= 26
1876
+
1868
1877
requires requires {
1869
- { __x.error () == __y.error () } -> __boolean_testable ;
1878
+ { __x.error () == __y.error () } -> __core_convertible_to< bool > ;
1870
1879
}
1880
+ # endif
1871
1881
{
1872
1882
if (__x.__has_val () != __y.__has_val ()) {
1873
1883
return false ;
@@ -1878,9 +1888,12 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
1878
1888
1879
1889
template <class _E2 >
1880
1890
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(const expected& __x, const unexpected<_E2>& __y)
1891
+ # if _LIBCPP_STD_VER >= 26
1892
+
1881
1893
requires requires {
1882
- { __x.error () == __y.error () } -> __boolean_testable ;
1894
+ { __x.error () == __y.error () } -> __core_convertible_to< bool > ;
1883
1895
}
1896
+ # endif
1884
1897
{
1885
1898
return !__x.__has_val () && static_cast <bool >(__x.__unex () == __y.error ());
1886
1899
}
0 commit comments