@@ -205,7 +205,6 @@ namespace std {
205
205
# include < __type_traits/is_assignable.h>
206
206
# include < __type_traits/is_constructible.h>
207
207
# include < __type_traits/is_convertible.h>
208
- # include < __type_traits/is_core_convertible.h>
209
208
# include < __type_traits/is_destructible.h>
210
209
# include < __type_traits/is_nothrow_assignable.h>
211
210
# include < __type_traits/is_nothrow_constructible.h>
@@ -983,133 +982,72 @@ public:
983
982
template <class _Tp >
984
983
optional (_Tp) -> optional<_Tp>;
985
984
986
- // [optional.relops] Relational operators
987
-
988
- # if _LIBCPP_STD_VER >= 26
989
- template < class _Tp , class _Up >
990
- # else
985
+ // Comparisons between optionals
991
986
template <
992
987
class _Tp ,
993
988
class _Up ,
994
989
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() == std::declval<const _Up&>()), bool >, int > = 0 >
995
- # endif
996
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const optional<_Tp>& __x, const optional<_Up>& __y)
997
- # if _LIBCPP_STD_VER >= 26
998
- requires requires {
999
- { *__x == *__y } -> __core_convertible_to<bool >;
1000
- }
1001
- # endif
1002
- {
990
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const optional<_Tp>& __x, const optional<_Up>& __y) {
1003
991
if (static_cast <bool >(__x) != static_cast <bool >(__y))
1004
992
return false ;
1005
993
if (!static_cast <bool >(__x))
1006
994
return true ;
1007
995
return *__x == *__y;
1008
996
}
1009
997
1010
- # if _LIBCPP_STD_VER >= 26
1011
- template < class _Tp , class _Up >
1012
- # else
1013
998
template <
1014
999
class _Tp ,
1015
1000
class _Up ,
1016
1001
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() != std::declval<const _Up&>()), bool >, int > = 0 >
1017
- # endif
1018
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const optional<_Tp>& __x, const optional<_Up>& __y)
1019
- # if _LIBCPP_STD_VER >= 26
1020
- requires requires {
1021
- { *__x != *__y } -> __core_convertible_to<bool >;
1022
- }
1023
- # endif
1024
- {
1002
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1025
1003
if (static_cast <bool >(__x) != static_cast <bool >(__y))
1026
1004
return true ;
1027
1005
if (!static_cast <bool >(__x))
1028
1006
return false ;
1029
1007
return *__x != *__y;
1030
1008
}
1031
1009
1032
- # if _LIBCPP_STD_VER >= 26
1033
- template < class _Tp , class _Up >
1034
- # else
1035
1010
template <
1036
1011
class _Tp ,
1037
1012
class _Up ,
1038
1013
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() < std::declval<const _Up&>()), bool >, int > = 0 >
1039
- # endif
1040
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const optional<_Tp>& __x, const optional<_Up>& __y)
1041
- # if _LIBCPP_STD_VER >= 26
1042
- requires requires {
1043
- { *__x < *__y } -> __core_convertible_to<bool >;
1044
- }
1045
- # endif
1046
- {
1014
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const optional<_Tp>& __x, const optional<_Up>& __y) {
1047
1015
if (!static_cast <bool >(__y))
1048
1016
return false ;
1049
1017
if (!static_cast <bool >(__x))
1050
1018
return true ;
1051
1019
return *__x < *__y;
1052
1020
}
1053
1021
1054
- # if _LIBCPP_STD_VER >= 26
1055
- template < class _Tp , class _Up >
1056
- # else
1057
1022
template <
1058
1023
class _Tp ,
1059
1024
class _Up ,
1060
1025
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() > std::declval<const _Up&>()), bool >, int > = 0 >
1061
- # endif
1062
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const optional<_Tp>& __x, const optional<_Up>& __y)
1063
- # if _LIBCPP_STD_VER >= 26
1064
- requires requires {
1065
- { *__x > *__y } -> __core_convertible_to<bool >;
1066
- }
1067
- # endif
1068
- {
1026
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const optional<_Tp>& __x, const optional<_Up>& __y) {
1069
1027
if (!static_cast <bool >(__x))
1070
1028
return false ;
1071
1029
if (!static_cast <bool >(__y))
1072
1030
return true ;
1073
1031
return *__x > *__y;
1074
1032
}
1075
1033
1076
- # if _LIBCPP_STD_VER >= 26
1077
- template < class _Tp , class _Up >
1078
- # else
1079
1034
template <
1080
1035
class _Tp ,
1081
1036
class _Up ,
1082
1037
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool >, int > = 0 >
1083
- # endif
1084
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const optional<_Tp>& __x, const optional<_Up>& __y)
1085
- # if _LIBCPP_STD_VER >= 26
1086
- requires requires {
1087
- { *__x <= *__y } -> __core_convertible_to<bool >;
1088
- }
1089
- # endif
1090
- {
1038
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1091
1039
if (!static_cast <bool >(__x))
1092
1040
return true ;
1093
1041
if (!static_cast <bool >(__y))
1094
1042
return false ;
1095
1043
return *__x <= *__y;
1096
1044
}
1097
1045
1098
- # if _LIBCPP_STD_VER >= 26
1099
- template < class _Tp , class _Up >
1100
- # else
1101
1046
template <
1102
1047
class _Tp ,
1103
1048
class _Up ,
1104
1049
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool >, int > = 0 >
1105
- # endif
1106
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const optional<_Tp>& __x, const optional<_Up>& __y)
1107
- # if _LIBCPP_STD_VER >= 26
1108
- requires requires {
1109
- { *__x >= *__y } -> __core_convertible_to<bool >;
1110
- }
1111
- # endif
1112
- {
1050
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1113
1051
if (!static_cast <bool >(__y))
1114
1052
return true ;
1115
1053
if (!static_cast <bool >(__x))
@@ -1129,8 +1067,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {
1129
1067
1130
1068
# endif // _LIBCPP_STD_VER >= 20
1131
1069
1132
- // [optional.nullops] Comparison with nullopt
1133
-
1070
+ // Comparisons with nullopt
1134
1071
template <class _Tp >
1135
1072
_LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const optional<_Tp>& __x, nullopt_t ) noexcept {
1136
1073
return !static_cast <bool >(__x);
@@ -1202,221 +1139,100 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>&
1202
1139
1203
1140
# endif // _LIBCPP_STD_VER <= 17
1204
1141
1205
- // [optional.comp.with.t] Comparison with T
1206
-
1207
- # if _LIBCPP_STD_VER >= 26
1208
- template < class _Tp , class _Up >
1209
- # else
1142
+ // Comparisons with T
1210
1143
template <
1211
1144
class _Tp ,
1212
1145
class _Up ,
1213
1146
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() == std::declval<const _Up&>()), bool >, int > = 0 >
1214
- # endif
1215
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const optional<_Tp>& __x, const _Up& __v)
1216
- # if _LIBCPP_STD_VER >= 26
1217
- requires (!__is_std_optional<_Up>::value) && requires {
1218
- { *__x == __v } -> __core_convertible_to<bool >;
1219
- }
1220
- # endif
1221
- {
1147
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const optional<_Tp>& __x, const _Up& __v) {
1222
1148
return static_cast <bool >(__x) ? *__x == __v : false ;
1223
1149
}
1224
1150
1225
- # if _LIBCPP_STD_VER >= 26
1226
- template < class _Tp , class _Up >
1227
- # else
1228
1151
template <
1229
1152
class _Tp ,
1230
1153
class _Up ,
1231
1154
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() == std::declval<const _Up&>()), bool >, int > = 0 >
1232
- # endif
1233
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const _Tp& __v, const optional<_Up>& __x)
1234
- # if _LIBCPP_STD_VER >= 26
1235
- requires (!__is_std_optional<_Tp>::value) && requires {
1236
- { __v == *__x } -> __core_convertible_to<bool >;
1237
- }
1238
- # endif
1239
- {
1155
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator ==(const _Tp& __v, const optional<_Up>& __x) {
1240
1156
return static_cast <bool >(__x) ? __v == *__x : false ;
1241
1157
}
1242
1158
1243
- # if _LIBCPP_STD_VER >= 26
1244
- template < class _Tp , class _Up >
1245
- # else
1246
1159
template <
1247
1160
class _Tp ,
1248
1161
class _Up ,
1249
1162
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() != std::declval<const _Up&>()), bool >, int > = 0 >
1250
- # endif
1251
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const optional<_Tp>& __x, const _Up& __v)
1252
- # if _LIBCPP_STD_VER >= 26
1253
- requires (!__is_std_optional<_Up>::value) && requires {
1254
- { *__x != __v } -> __core_convertible_to<bool >;
1255
- }
1256
- # endif
1257
- {
1163
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const optional<_Tp>& __x, const _Up& __v) {
1258
1164
return static_cast <bool >(__x) ? *__x != __v : true ;
1259
1165
}
1260
1166
1261
- # if _LIBCPP_STD_VER >= 26
1262
- template < class _Tp , class _Up >
1263
- # else
1264
1167
template <
1265
1168
class _Tp ,
1266
1169
class _Up ,
1267
1170
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() != std::declval<const _Up&>()), bool >, int > = 0 >
1268
- # endif
1269
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const _Tp& __v, const optional<_Up>& __x)
1270
- # if _LIBCPP_STD_VER >= 26
1271
- requires (!__is_std_optional<_Tp>::value) && requires {
1272
- { __v != *__x } -> __core_convertible_to<bool >;
1273
- }
1274
- # endif
1275
- {
1171
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator !=(const _Tp& __v, const optional<_Up>& __x) {
1276
1172
return static_cast <bool >(__x) ? __v != *__x : true ;
1277
1173
}
1278
1174
1279
- # if _LIBCPP_STD_VER >= 26
1280
- template < class _Tp , class _Up >
1281
- # else
1282
1175
template <
1283
1176
class _Tp ,
1284
1177
class _Up ,
1285
1178
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() < std::declval<const _Up&>()), bool >, int > = 0 >
1286
- # endif
1287
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const optional<_Tp>& __x, const _Up& __v)
1288
- # if _LIBCPP_STD_VER >= 26
1289
- requires (!__is_std_optional<_Up>::value) && requires {
1290
- { *__x < __v } -> __core_convertible_to<bool >;
1291
- }
1292
- # endif
1293
- {
1179
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const optional<_Tp>& __x, const _Up& __v) {
1294
1180
return static_cast <bool >(__x) ? *__x < __v : true ;
1295
1181
}
1296
1182
1297
- # if _LIBCPP_STD_VER >= 26
1298
- template < class _Tp , class _Up >
1299
- # else
1300
1183
template <
1301
1184
class _Tp ,
1302
1185
class _Up ,
1303
1186
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() < std::declval<const _Up&>()), bool >, int > = 0 >
1304
- # endif
1305
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const _Tp& __v, const optional<_Up>& __x)
1306
- # if _LIBCPP_STD_VER >= 26
1307
- requires (!__is_std_optional<_Tp>::value) && requires {
1308
- { __v < *__x } -> __core_convertible_to<bool >;
1309
- }
1310
- # endif
1311
- {
1187
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <(const _Tp& __v, const optional<_Up>& __x) {
1312
1188
return static_cast <bool >(__x) ? __v < *__x : false ;
1313
1189
}
1314
1190
1315
- # if _LIBCPP_STD_VER >= 26
1316
- template < class _Tp , class _Up >
1317
- # else
1318
1191
template <
1319
1192
class _Tp ,
1320
1193
class _Up ,
1321
1194
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool >, int > = 0 >
1322
- # endif
1323
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const optional<_Tp>& __x, const _Up& __v)
1324
- # if _LIBCPP_STD_VER >= 26
1325
- requires (!__is_std_optional<_Up>::value) && requires {
1326
- { *__x <= __v } -> __core_convertible_to<bool >;
1327
- }
1328
- # endif
1329
- {
1195
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const optional<_Tp>& __x, const _Up& __v) {
1330
1196
return static_cast <bool >(__x) ? *__x <= __v : true ;
1331
1197
}
1332
1198
1333
- # if _LIBCPP_STD_VER >= 26
1334
- template < class _Tp , class _Up >
1335
- # else
1336
1199
template <
1337
1200
class _Tp ,
1338
1201
class _Up ,
1339
1202
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool >, int > = 0 >
1340
- # endif
1341
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const _Tp& __v, const optional<_Up>& __x)
1342
- # if _LIBCPP_STD_VER >= 26
1343
- requires (!__is_std_optional<_Tp>::value) && requires {
1344
- { __v <= *__x } -> __core_convertible_to<bool >;
1345
- }
1346
- # endif
1347
- {
1203
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator <=(const _Tp& __v, const optional<_Up>& __x) {
1348
1204
return static_cast <bool >(__x) ? __v <= *__x : false ;
1349
1205
}
1350
1206
1351
- # if _LIBCPP_STD_VER >= 26
1352
- template < class _Tp , class _Up >
1353
- # else
1354
1207
template <
1355
1208
class _Tp ,
1356
1209
class _Up ,
1357
1210
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() > std::declval<const _Up&>()), bool >, int > = 0 >
1358
- # endif
1359
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const optional<_Tp>& __x, const _Up& __v)
1360
- # if _LIBCPP_STD_VER >= 26
1361
- requires (!__is_std_optional<_Up>::value) && requires {
1362
- { *__x > __v } -> __core_convertible_to<bool >;
1363
- }
1364
- # endif
1365
- {
1211
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const optional<_Tp>& __x, const _Up& __v) {
1366
1212
return static_cast <bool >(__x) ? *__x > __v : false ;
1367
1213
}
1368
1214
1369
- # if _LIBCPP_STD_VER >= 26
1370
- template < class _Tp , class _Up >
1371
- # else
1372
1215
template <
1373
1216
class _Tp ,
1374
1217
class _Up ,
1375
1218
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() > std::declval<const _Up&>()), bool >, int > = 0 >
1376
- # endif
1377
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const _Tp& __v, const optional<_Up>& __x)
1378
- # if _LIBCPP_STD_VER >= 26
1379
- requires (!__is_std_optional<_Tp>::value) && requires {
1380
- { __v > *__x } -> __core_convertible_to<bool >;
1381
- }
1382
- # endif
1383
- {
1219
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >(const _Tp& __v, const optional<_Up>& __x) {
1384
1220
return static_cast <bool >(__x) ? __v > *__x : true ;
1385
1221
}
1386
1222
1387
- # if _LIBCPP_STD_VER >= 26
1388
- template < class _Tp , class _Up >
1389
- # else
1390
1223
template <
1391
1224
class _Tp ,
1392
1225
class _Up ,
1393
1226
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool >, int > = 0 >
1394
- # endif
1395
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const optional<_Tp>& __x, const _Up& __v)
1396
- # if _LIBCPP_STD_VER >= 26
1397
- requires (!__is_std_optional<_Up>::value) && requires {
1398
- { *__x >= __v } -> __core_convertible_to<bool >;
1399
- }
1400
- # endif
1401
- {
1227
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const optional<_Tp>& __x, const _Up& __v) {
1402
1228
return static_cast <bool >(__x) ? *__x >= __v : false ;
1403
1229
}
1404
1230
1405
- # if _LIBCPP_STD_VER >= 26
1406
- template < class _Tp , class _Up >
1407
- # else
1408
1231
template <
1409
1232
class _Tp ,
1410
1233
class _Up ,
1411
1234
enable_if_t <is_convertible_v<decltype (std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool >, int > = 0 >
1412
- # endif
1413
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const _Tp& __v, const optional<_Up>& __x)
1414
- # if _LIBCPP_STD_VER >= 26
1415
- requires (!__is_std_optional<_Tp>::value) && requires {
1416
- { __v >= *__x } -> __core_convertible_to<bool >;
1417
- }
1418
- # endif
1419
- {
1235
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator >=(const _Tp& __v, const optional<_Up>& __x) {
1420
1236
return static_cast <bool >(__x) ? __v >= *__x : true ;
1421
1237
}
1422
1238
0 commit comments