@@ -173,10 +173,22 @@ public:
173
173
174
174
iterator find(const key_type& k);
175
175
const_iterator find(const key_type& k) const;
176
+ template<typename K>
177
+ iterator find(const K& x); // C++20
178
+ template<typename K>
179
+ const_iterator find(const K& x) const; // C++20
176
180
size_type count(const key_type& k) const;
181
+ template<typename K>
182
+ size_type count(const K& k) const; // C++20
177
183
bool contains(const key_type& k) const; // C++20
184
+ template<typename K>
185
+ bool contains(const K& k) const; // C++20
178
186
pair<iterator, iterator> equal_range(const key_type& k);
179
187
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
188
+ template<typename K>
189
+ pair<iterator, iterator> equal_range(const K& k); // C++20
190
+ template<typename K>
191
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
180
192
181
193
mapped_type& operator[](const key_type& k);
182
194
mapped_type& operator[](key_type&& k);
@@ -355,10 +367,22 @@ public:
355
367
356
368
iterator find(const key_type& k);
357
369
const_iterator find(const key_type& k) const;
370
+ template<typename K>
371
+ iterator find(const K& x); // C++20
372
+ template<typename K>
373
+ const_iterator find(const K& x) const; // C++20
358
374
size_type count(const key_type& k) const;
375
+ template<typename K>
376
+ size_type count(const K& k) const; // C++20
359
377
bool contains(const key_type& k) const; // C++20
378
+ template<typename K>
379
+ bool contains(const K& k) const; // C++20
360
380
pair<iterator, iterator> equal_range(const key_type& k);
361
381
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
382
+ template<typename K>
383
+ pair<iterator, iterator> equal_range(const K& k); // C++20
384
+ template<typename K>
385
+ pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
362
386
363
387
size_type bucket_count() const noexcept;
364
388
size_type max_bucket_count() const noexcept;
@@ -423,7 +447,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
423
447
424
448
_LIBCPP_BEGIN_NAMESPACE_STD
425
449
426
- template <class _Key , class _Cp , class _Hash ,
450
+ template <class _Key , class _Cp , class _Hash , class _Pred ,
427
451
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
428
452
class __unordered_map_hasher
429
453
: private _Hash
@@ -445,6 +469,12 @@ public:
445
469
_LIBCPP_INLINE_VISIBILITY
446
470
size_t operator ()(const _Key& __x) const
447
471
{return static_cast <const _Hash&>(*this )(__x);}
472
+ #if _LIBCPP_STD_VER > 17
473
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
474
+ _LIBCPP_INLINE_VISIBILITY
475
+ size_t operator ()(const _K2& __x) const
476
+ {return static_cast <const _Hash&>(*this )(__x);}
477
+ #endif
448
478
void swap (__unordered_map_hasher&__y)
449
479
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
450
480
{
@@ -453,8 +483,8 @@ public:
453
483
}
454
484
};
455
485
456
- template <class _Key , class _Cp , class _Hash >
457
- class __unordered_map_hasher <_Key, _Cp, _Hash, false >
486
+ template <class _Key , class _Cp , class _Hash , class _Pred >
487
+ class __unordered_map_hasher <_Key, _Cp, _Hash, _Pred, false >
458
488
{
459
489
_Hash __hash_;
460
490
public:
@@ -474,6 +504,12 @@ public:
474
504
_LIBCPP_INLINE_VISIBILITY
475
505
size_t operator ()(const _Key& __x) const
476
506
{return __hash_ (__x);}
507
+ #if _LIBCPP_STD_VER > 17
508
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
509
+ _LIBCPP_INLINE_VISIBILITY
510
+ size_t operator ()(const _K2& __x) const
511
+ {return __hash_ (__x);}
512
+ #endif
477
513
void swap (__unordered_map_hasher&__y)
478
514
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
479
515
{
@@ -482,17 +518,17 @@ public:
482
518
}
483
519
};
484
520
485
- template <class _Key , class _Cp , class _Hash , bool __b>
521
+ template <class _Key , class _Cp , class _Hash , class _Pred , bool __b>
486
522
inline _LIBCPP_INLINE_VISIBILITY
487
523
void
488
- swap (__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
489
- __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
524
+ swap (__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
525
+ __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
490
526
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
491
527
{
492
528
__x.swap (__y);
493
529
}
494
530
495
- template <class _Key , class _Cp , class _Pred ,
531
+ template <class _Key , class _Cp , class _Pred , class _Hash ,
496
532
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
497
533
class __unordered_map_equal
498
534
: private _Pred
@@ -517,6 +553,24 @@ public:
517
553
_LIBCPP_INLINE_VISIBILITY
518
554
bool operator ()(const _Key& __x, const _Cp& __y) const
519
555
{return static_cast <const _Pred&>(*this )(__x, __y.__get_value ().first );}
556
+ #if _LIBCPP_STD_VER > 17
557
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
558
+ _LIBCPP_INLINE_VISIBILITY
559
+ bool operator ()(const _Cp& __x, const _K2& __y) const
560
+ {return static_cast <const _Pred&>(*this )(__x.__get_value ().first , __y);}
561
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
562
+ _LIBCPP_INLINE_VISIBILITY
563
+ bool operator ()(const _K2& __x, const _Cp& __y) const
564
+ {return static_cast <const _Pred&>(*this )(__x, __y.__get_value ().first );}
565
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
566
+ _LIBCPP_INLINE_VISIBILITY
567
+ bool operator ()(const _Key& __x, const _K2& __y) const
568
+ {return static_cast <const _Pred&>(*this )(__x, __y);}
569
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
570
+ _LIBCPP_INLINE_VISIBILITY
571
+ bool operator ()(const _K2& __x, const _Key& __y) const
572
+ {return static_cast <const _Pred&>(*this )(__x, __y);}
573
+ #endif
520
574
void swap (__unordered_map_equal&__y)
521
575
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
522
576
{
@@ -525,8 +579,8 @@ public:
525
579
}
526
580
};
527
581
528
- template <class _Key , class _Cp , class _Pred >
529
- class __unordered_map_equal <_Key, _Cp, _Pred, false >
582
+ template <class _Key , class _Cp , class _Pred , class _Hash >
583
+ class __unordered_map_equal <_Key, _Cp, _Pred, _Hash, false >
530
584
{
531
585
_Pred __pred_;
532
586
public:
@@ -549,6 +603,24 @@ public:
549
603
_LIBCPP_INLINE_VISIBILITY
550
604
bool operator ()(const _Key& __x, const _Cp& __y) const
551
605
{return __pred_ (__x, __y.__get_value ().first );}
606
+ #if _LIBCPP_STD_VER > 17
607
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
608
+ _LIBCPP_INLINE_VISIBILITY
609
+ bool operator ()(const _Cp& __x, const _K2& __y) const
610
+ {return __pred_ (__x.__get_value ().first , __y);}
611
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
612
+ _LIBCPP_INLINE_VISIBILITY
613
+ bool operator ()(const _K2& __x, const _Cp& __y) const
614
+ {return __pred_ (__x, __y.__get_value ().first );}
615
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
616
+ _LIBCPP_INLINE_VISIBILITY
617
+ bool operator ()(const _Key& __x, const _K2& __y) const
618
+ {return __pred_ (__x, __y);}
619
+ template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
620
+ _LIBCPP_INLINE_VISIBILITY
621
+ bool operator ()(const _K2& __x, const _Key& __y) const
622
+ {return __pred_ (__x, __y);}
623
+ #endif
552
624
void swap (__unordered_map_equal&__y)
553
625
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
554
626
{
@@ -557,11 +629,11 @@ public:
557
629
}
558
630
};
559
631
560
- template <class _Key , class _Cp , class _Pred , bool __b>
632
+ template <class _Key , class _Cp , class _Pred , class _Hash , bool __b>
561
633
inline _LIBCPP_INLINE_VISIBILITY
562
634
void
563
- swap (__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
564
- __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
635
+ swap (__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
636
+ __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
565
637
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
566
638
{
567
639
__x.swap (__y);
@@ -858,11 +930,11 @@ public:
858
930
" Invalid allocator::value_type" );
859
931
860
932
private:
861
- typedef __hash_value_type<key_type, mapped_type> __value_type;
862
- typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
863
- typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
933
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
934
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
935
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
864
936
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
865
- __value_type>::type __allocator_type;
937
+ __value_type>::type __allocator_type;
866
938
867
939
typedef __hash_table<__value_type, __hasher,
868
940
__key_equal, __allocator_type> __table;
@@ -1280,18 +1352,51 @@ public:
1280
1352
iterator find (const key_type& __k) {return __table_.find (__k);}
1281
1353
_LIBCPP_INLINE_VISIBILITY
1282
1354
const_iterator find (const key_type& __k) const {return __table_.find (__k);}
1355
+
1356
+ #if _LIBCPP_STD_VER > 17
1357
+ template <typename _K2>
1358
+ _LIBCPP_INLINE_VISIBILITY
1359
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
1360
+ find (const _K2& __k) {return __table_.find (__k);}
1361
+ template <typename _K2>
1362
+ _LIBCPP_INLINE_VISIBILITY
1363
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
1364
+ find (const _K2& __k) const {return __table_.find (__k);}
1365
+ #endif // _LIBCPP_STD_VER > 17
1366
+
1283
1367
_LIBCPP_INLINE_VISIBILITY
1284
1368
size_type count (const key_type& __k) const {return __table_.__count_unique (__k);}
1369
+ #if _LIBCPP_STD_VER > 17
1370
+ template <typename _K2>
1371
+ _LIBCPP_INLINE_VISIBILITY
1372
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
1373
+ count (const _K2& __k) const {return __table_.__count_unique (__k);}
1374
+ #endif // _LIBCPP_STD_VER > 17
1285
1375
#if _LIBCPP_STD_VER > 17
1286
1376
_LIBCPP_INLINE_VISIBILITY
1287
1377
bool contains (const key_type& __k) const {return find (__k) != end ();}
1378
+
1379
+ template <typename _K2>
1380
+ _LIBCPP_INLINE_VISIBILITY
1381
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool >
1382
+ contains (const _K2& __k) const {return find (__k) != end ();}
1288
1383
#endif // _LIBCPP_STD_VER > 17
1289
1384
_LIBCPP_INLINE_VISIBILITY
1290
1385
pair<iterator, iterator> equal_range (const key_type& __k)
1291
1386
{return __table_.__equal_range_unique (__k);}
1292
1387
_LIBCPP_INLINE_VISIBILITY
1293
1388
pair<const_iterator, const_iterator> equal_range (const key_type& __k) const
1294
1389
{return __table_.__equal_range_unique (__k);}
1390
+ #if _LIBCPP_STD_VER > 17
1391
+ template <typename _K2>
1392
+ _LIBCPP_INLINE_VISIBILITY
1393
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
1394
+ equal_range (const _K2& __k) {return __table_.__equal_range_unique (__k);}
1395
+ template <typename _K2>
1396
+ _LIBCPP_INLINE_VISIBILITY
1397
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
1398
+ equal_range (const _K2& __k) const {return __table_.__equal_range_unique (__k);}
1399
+ #endif // _LIBCPP_STD_VER > 17
1295
1400
1296
1401
mapped_type& operator [](const key_type& __k);
1297
1402
#ifndef _LIBCPP_CXX03_LANG
@@ -1762,11 +1867,11 @@ public:
1762
1867
" Invalid allocator::value_type" );
1763
1868
1764
1869
private:
1765
- typedef __hash_value_type<key_type, mapped_type> __value_type;
1766
- typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
1767
- typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
1870
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
1871
+ typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1872
+ typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1768
1873
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1769
- __value_type>::type __allocator_type;
1874
+ __value_type>::type __allocator_type;
1770
1875
1771
1876
typedef __hash_table<__value_type, __hasher,
1772
1877
__key_equal, __allocator_type> __table;
@@ -2059,18 +2164,49 @@ public:
2059
2164
iterator find (const key_type& __k) {return __table_.find (__k);}
2060
2165
_LIBCPP_INLINE_VISIBILITY
2061
2166
const_iterator find (const key_type& __k) const {return __table_.find (__k);}
2167
+ #if _LIBCPP_STD_VER > 17
2168
+ template <typename _K2>
2169
+ _LIBCPP_INLINE_VISIBILITY
2170
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
2171
+ find (const _K2& __k) {return __table_.find (__k);}
2172
+ template <typename _K2>
2173
+ _LIBCPP_INLINE_VISIBILITY
2174
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
2175
+ find (const _K2& __k) const {return __table_.find (__k);}
2176
+ #endif // _LIBCPP_STD_VER > 17
2062
2177
_LIBCPP_INLINE_VISIBILITY
2063
2178
size_type count (const key_type& __k) const {return __table_.__count_multi (__k);}
2179
+ #if _LIBCPP_STD_VER > 17
2180
+ template <typename _K2>
2181
+ _LIBCPP_INLINE_VISIBILITY
2182
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
2183
+ count (const _K2& __k) const {return __table_.__count_multi (__k);}
2184
+ #endif // _LIBCPP_STD_VER > 17
2064
2185
#if _LIBCPP_STD_VER > 17
2065
2186
_LIBCPP_INLINE_VISIBILITY
2066
2187
bool contains (const key_type& __k) const {return find (__k) != end ();}
2188
+
2189
+ template <typename _K2>
2190
+ _LIBCPP_INLINE_VISIBILITY
2191
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool >
2192
+ contains (const _K2& __k) const {return find (__k) != end ();}
2067
2193
#endif // _LIBCPP_STD_VER > 17
2068
2194
_LIBCPP_INLINE_VISIBILITY
2069
2195
pair<iterator, iterator> equal_range (const key_type& __k)
2070
2196
{return __table_.__equal_range_multi (__k);}
2071
2197
_LIBCPP_INLINE_VISIBILITY
2072
2198
pair<const_iterator, const_iterator> equal_range (const key_type& __k) const
2073
2199
{return __table_.__equal_range_multi (__k);}
2200
+ #if _LIBCPP_STD_VER > 17
2201
+ template <typename _K2>
2202
+ _LIBCPP_INLINE_VISIBILITY
2203
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
2204
+ equal_range (const _K2& __k) {return __table_.__equal_range_multi (__k);}
2205
+ template <typename _K2>
2206
+ _LIBCPP_INLINE_VISIBILITY
2207
+ _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
2208
+ equal_range (const _K2& __k) const {return __table_.__equal_range_multi (__k);}
2209
+ #endif // _LIBCPP_STD_VER > 17
2074
2210
2075
2211
_LIBCPP_INLINE_VISIBILITY
2076
2212
size_type bucket_count () const _NOEXCEPT {return __table_.bucket_count ();}
0 commit comments