@@ -600,7 +600,10 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
600
600
# include < __ranges/from_range.h>
601
601
# include < __tree>
602
602
# include < __type_traits/container_traits.h>
603
+ # include < __type_traits/desugars_to.h>
603
604
# include < __type_traits/is_allocator.h>
605
+ # include < __type_traits/is_convertible.h>
606
+ # include < __type_traits/make_transparent.h>
604
607
# include < __type_traits/remove_const.h>
605
608
# include < __type_traits/type_identity.h>
606
609
# include < __utility/forward.h>
@@ -666,6 +669,11 @@ public:
666
669
# endif
667
670
};
668
671
672
+ template <class _Key , class _MapValueT , class _Compare >
673
+ struct __make_transparent <__map_value_compare<_Key, _MapValueT, _Compare> > {
674
+ using type _LIBCPP_NODEBUG = __map_value_compare<_Key, _MapValueT, __make_transparent_t <_Compare> >;
675
+ };
676
+
669
677
# if _LIBCPP_STD_VER >= 14
670
678
template <class _MapValueT , class _Key , class _Compare >
671
679
struct __lazy_synth_three_way_comparator <__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _MapValueT> {
@@ -1048,6 +1056,24 @@ public:
1048
1056
_LIBCPP_HIDE_FROM_ABI mapped_type& operator [](key_type&& __k);
1049
1057
# endif
1050
1058
1059
+ template <class _Arg ,
1060
+ __enable_if_t <__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t <_Arg> >, int > = 0 >
1061
+ _LIBCPP_HIDE_FROM_ABI mapped_type& at (_Arg&& __arg) {
1062
+ auto [_, __child] = __tree_.__find_equal (__arg);
1063
+ if (__child == nullptr )
1064
+ std::__throw_out_of_range (" map::at: key not found" );
1065
+ return static_cast <__node_pointer>(__child)->__get_value ().second ;
1066
+ }
1067
+
1068
+ template <class _Arg ,
1069
+ __enable_if_t <__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t <_Arg> >, int > = 0 >
1070
+ _LIBCPP_HIDE_FROM_ABI const mapped_type& at (_Arg&& __arg) const {
1071
+ auto [_, __child] = __tree_.__find_equal (__arg);
1072
+ if (__child == nullptr )
1073
+ std::__throw_out_of_range (" map::at: key not found" );
1074
+ return static_cast <__node_pointer>(__child)->__get_value ().second ;
1075
+ }
1076
+
1051
1077
_LIBCPP_HIDE_FROM_ABI mapped_type& at (const key_type& __k);
1052
1078
_LIBCPP_HIDE_FROM_ABI const mapped_type& at (const key_type& __k) const ;
1053
1079
@@ -1242,11 +1268,15 @@ public:
1242
1268
_LIBCPP_HIDE_FROM_ABI iterator find (const key_type& __k) { return __tree_.find (__k); }
1243
1269
_LIBCPP_HIDE_FROM_ABI const_iterator find (const key_type& __k) const { return __tree_.find (__k); }
1244
1270
# if _LIBCPP_STD_VER >= 14
1245
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1271
+ template <typename _K2,
1272
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1273
+ int > = 0 >
1246
1274
_LIBCPP_HIDE_FROM_ABI iterator find (const _K2& __k) {
1247
1275
return __tree_.find (__k);
1248
1276
}
1249
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1277
+ template <typename _K2,
1278
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1279
+ int > = 0 >
1250
1280
_LIBCPP_HIDE_FROM_ABI const_iterator find (const _K2& __k) const {
1251
1281
return __tree_.find (__k);
1252
1282
}
@@ -1262,7 +1292,9 @@ public:
1262
1292
1263
1293
# if _LIBCPP_STD_VER >= 20
1264
1294
_LIBCPP_HIDE_FROM_ABI bool contains (const key_type& __k) const { return find (__k) != end (); }
1265
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1295
+ template <typename _K2,
1296
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1297
+ int > = 0 >
1266
1298
_LIBCPP_HIDE_FROM_ABI bool contains (const _K2& __k) const {
1267
1299
return find (__k) != end ();
1268
1300
}
@@ -1271,12 +1303,16 @@ public:
1271
1303
_LIBCPP_HIDE_FROM_ABI iterator lower_bound (const key_type& __k) { return __tree_.lower_bound (__k); }
1272
1304
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound (const key_type& __k) const { return __tree_.lower_bound (__k); }
1273
1305
# if _LIBCPP_STD_VER >= 14
1274
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1306
+ template <typename _K2,
1307
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1308
+ int > = 0 >
1275
1309
_LIBCPP_HIDE_FROM_ABI iterator lower_bound (const _K2& __k) {
1276
1310
return __tree_.lower_bound (__k);
1277
1311
}
1278
1312
1279
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1313
+ template <typename _K2,
1314
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1315
+ int > = 0 >
1280
1316
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound (const _K2& __k) const {
1281
1317
return __tree_.lower_bound (__k);
1282
1318
}
@@ -1285,11 +1321,15 @@ public:
1285
1321
_LIBCPP_HIDE_FROM_ABI iterator upper_bound (const key_type& __k) { return __tree_.upper_bound (__k); }
1286
1322
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound (const key_type& __k) const { return __tree_.upper_bound (__k); }
1287
1323
# if _LIBCPP_STD_VER >= 14
1288
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1324
+ template <typename _K2,
1325
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1326
+ int > = 0 >
1289
1327
_LIBCPP_HIDE_FROM_ABI iterator upper_bound (const _K2& __k) {
1290
1328
return __tree_.upper_bound (__k);
1291
1329
}
1292
- template <typename _K2, enable_if_t <__is_transparent_v<_Compare, _K2>, int > = 0 >
1330
+ template <typename _K2,
1331
+ enable_if_t <__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1332
+ int > = 0 >
1293
1333
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound (const _K2& __k) const {
1294
1334
return __tree_.upper_bound (__k);
1295
1335
}
0 commit comments