Skip to content

Commit 4e1e312

Browse files
committed
Removed optional changes
1 parent 3a63752 commit 4e1e312

File tree

14 files changed

+21
-448
lines changed

14 files changed

+21
-448
lines changed

libcxx/include/optional

Lines changed: 21 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ namespace std {
205205
# include <__type_traits/is_assignable.h>
206206
# include <__type_traits/is_constructible.h>
207207
# include <__type_traits/is_convertible.h>
208-
# include <__type_traits/is_core_convertible.h>
209208
# include <__type_traits/is_destructible.h>
210209
# include <__type_traits/is_nothrow_assignable.h>
211210
# include <__type_traits/is_nothrow_constructible.h>
@@ -983,133 +982,72 @@ public:
983982
template <class _Tp>
984983
optional(_Tp) -> optional<_Tp>;
985984

986-
// [optional.relops] Relational operators
987-
988-
# if _LIBCPP_STD_VER >= 26
989-
template < class _Tp, class _Up>
990-
# else
985+
// Comparisons between optionals
991986
template <
992987
class _Tp,
993988
class _Up,
994989
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) {
1003991
if (static_cast<bool>(__x) != static_cast<bool>(__y))
1004992
return false;
1005993
if (!static_cast<bool>(__x))
1006994
return true;
1007995
return *__x == *__y;
1008996
}
1009997

1010-
# if _LIBCPP_STD_VER >= 26
1011-
template < class _Tp, class _Up>
1012-
# else
1013998
template <
1014999
class _Tp,
10151000
class _Up,
10161001
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) {
10251003
if (static_cast<bool>(__x) != static_cast<bool>(__y))
10261004
return true;
10271005
if (!static_cast<bool>(__x))
10281006
return false;
10291007
return *__x != *__y;
10301008
}
10311009

1032-
# if _LIBCPP_STD_VER >= 26
1033-
template < class _Tp, class _Up>
1034-
# else
10351010
template <
10361011
class _Tp,
10371012
class _Up,
10381013
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) {
10471015
if (!static_cast<bool>(__y))
10481016
return false;
10491017
if (!static_cast<bool>(__x))
10501018
return true;
10511019
return *__x < *__y;
10521020
}
10531021

1054-
# if _LIBCPP_STD_VER >= 26
1055-
template < class _Tp, class _Up>
1056-
# else
10571022
template <
10581023
class _Tp,
10591024
class _Up,
10601025
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) {
10691027
if (!static_cast<bool>(__x))
10701028
return false;
10711029
if (!static_cast<bool>(__y))
10721030
return true;
10731031
return *__x > *__y;
10741032
}
10751033

1076-
# if _LIBCPP_STD_VER >= 26
1077-
template < class _Tp, class _Up>
1078-
# else
10791034
template <
10801035
class _Tp,
10811036
class _Up,
10821037
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) {
10911039
if (!static_cast<bool>(__x))
10921040
return true;
10931041
if (!static_cast<bool>(__y))
10941042
return false;
10951043
return *__x <= *__y;
10961044
}
10971045

1098-
# if _LIBCPP_STD_VER >= 26
1099-
template < class _Tp, class _Up>
1100-
# else
11011046
template <
11021047
class _Tp,
11031048
class _Up,
11041049
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) {
11131051
if (!static_cast<bool>(__y))
11141052
return true;
11151053
if (!static_cast<bool>(__x))
@@ -1129,8 +1067,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {
11291067

11301068
# endif // _LIBCPP_STD_VER >= 20
11311069

1132-
// [optional.nullops] Comparison with nullopt
1133-
1070+
// Comparisons with nullopt
11341071
template <class _Tp>
11351072
_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept {
11361073
return !static_cast<bool>(__x);
@@ -1202,221 +1139,100 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>&
12021139

12031140
# endif // _LIBCPP_STD_VER <= 17
12041141

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
12101143
template <
12111144
class _Tp,
12121145
class _Up,
12131146
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) {
12221148
return static_cast<bool>(__x) ? *__x == __v : false;
12231149
}
12241150

1225-
# if _LIBCPP_STD_VER >= 26
1226-
template < class _Tp, class _Up>
1227-
# else
12281151
template <
12291152
class _Tp,
12301153
class _Up,
12311154
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) {
12401156
return static_cast<bool>(__x) ? __v == *__x : false;
12411157
}
12421158

1243-
# if _LIBCPP_STD_VER >= 26
1244-
template < class _Tp, class _Up>
1245-
# else
12461159
template <
12471160
class _Tp,
12481161
class _Up,
12491162
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) {
12581164
return static_cast<bool>(__x) ? *__x != __v : true;
12591165
}
12601166

1261-
# if _LIBCPP_STD_VER >= 26
1262-
template < class _Tp, class _Up>
1263-
# else
12641167
template <
12651168
class _Tp,
12661169
class _Up,
12671170
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) {
12761172
return static_cast<bool>(__x) ? __v != *__x : true;
12771173
}
12781174

1279-
# if _LIBCPP_STD_VER >= 26
1280-
template < class _Tp, class _Up>
1281-
# else
12821175
template <
12831176
class _Tp,
12841177
class _Up,
12851178
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) {
12941180
return static_cast<bool>(__x) ? *__x < __v : true;
12951181
}
12961182

1297-
# if _LIBCPP_STD_VER >= 26
1298-
template < class _Tp, class _Up>
1299-
# else
13001183
template <
13011184
class _Tp,
13021185
class _Up,
13031186
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) {
13121188
return static_cast<bool>(__x) ? __v < *__x : false;
13131189
}
13141190

1315-
# if _LIBCPP_STD_VER >= 26
1316-
template < class _Tp, class _Up>
1317-
# else
13181191
template <
13191192
class _Tp,
13201193
class _Up,
13211194
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) {
13301196
return static_cast<bool>(__x) ? *__x <= __v : true;
13311197
}
13321198

1333-
# if _LIBCPP_STD_VER >= 26
1334-
template < class _Tp, class _Up>
1335-
# else
13361199
template <
13371200
class _Tp,
13381201
class _Up,
13391202
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) {
13481204
return static_cast<bool>(__x) ? __v <= *__x : false;
13491205
}
13501206

1351-
# if _LIBCPP_STD_VER >= 26
1352-
template < class _Tp, class _Up>
1353-
# else
13541207
template <
13551208
class _Tp,
13561209
class _Up,
13571210
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) {
13661212
return static_cast<bool>(__x) ? *__x > __v : false;
13671213
}
13681214

1369-
# if _LIBCPP_STD_VER >= 26
1370-
template < class _Tp, class _Up>
1371-
# else
13721215
template <
13731216
class _Tp,
13741217
class _Up,
13751218
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) {
13841220
return static_cast<bool>(__x) ? __v > *__x : true;
13851221
}
13861222

1387-
# if _LIBCPP_STD_VER >= 26
1388-
template < class _Tp, class _Up>
1389-
# else
13901223
template <
13911224
class _Tp,
13921225
class _Up,
13931226
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) {
14021228
return static_cast<bool>(__x) ? *__x >= __v : false;
14031229
}
14041230

1405-
# if _LIBCPP_STD_VER >= 26
1406-
template < class _Tp, class _Up>
1407-
# else
14081231
template <
14091232
class _Tp,
14101233
class _Up,
14111234
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) {
14201236
return static_cast<bool>(__x) ? __v >= *__x : true;
14211237
}
14221238

0 commit comments

Comments
 (0)