Skip to content

Commit 3aba4b5

Browse files
authored
[libc++][NFC] Refactor __is_transparent to be a variable template (#90865)
1 parent bafbe39 commit 3aba4b5

File tree

5 files changed

+66
-87
lines changed

5 files changed

+66
-87
lines changed

libcxx/include/__functional/is_transparent.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
1212

1313
#include <__config>
14-
#include <__type_traits/integral_constant.h>
1514
#include <__type_traits/void_t.h>
1615

1716
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -23,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2322
#if _LIBCPP_STD_VER >= 14
2423

2524
template <class _Tp, class, class = void>
26-
struct __is_transparent : false_type {};
25+
inline const bool __is_transparent_v = false;
2726

2827
template <class _Tp, class _Up>
29-
struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> > : true_type {};
28+
inline const bool __is_transparent_v<_Tp, _Up, __void_t<typename _Tp::is_transparent> > = true;
3029

3130
#endif
3231

libcxx/include/map

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,27 +1367,27 @@ public:
13671367
_LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
13681368
_LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
13691369
#if _LIBCPP_STD_VER >= 14
1370-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1370+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13711371
_LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
13721372
return __tree_.find(__k);
13731373
}
1374-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1374+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13751375
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
13761376
return __tree_.find(__k);
13771377
}
13781378
#endif
13791379

13801380
_LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
13811381
#if _LIBCPP_STD_VER >= 14
1382-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1382+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13831383
_LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
13841384
return __tree_.__count_multi(__k);
13851385
}
13861386
#endif
13871387

13881388
#if _LIBCPP_STD_VER >= 20
13891389
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1390-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1390+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13911391
_LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
13921392
return find(__k) != end();
13931393
}
@@ -1396,12 +1396,12 @@ public:
13961396
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
13971397
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
13981398
#if _LIBCPP_STD_VER >= 14
1399-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1399+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14001400
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
14011401
return __tree_.lower_bound(__k);
14021402
}
14031403

1404-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1404+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14051405
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
14061406
return __tree_.lower_bound(__k);
14071407
}
@@ -1410,11 +1410,11 @@ public:
14101410
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
14111411
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
14121412
#if _LIBCPP_STD_VER >= 14
1413-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1413+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14141414
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
14151415
return __tree_.upper_bound(__k);
14161416
}
1417-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1417+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14181418
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
14191419
return __tree_.upper_bound(__k);
14201420
}
@@ -1427,11 +1427,11 @@ public:
14271427
return __tree_.__equal_range_unique(__k);
14281428
}
14291429
#if _LIBCPP_STD_VER >= 14
1430-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1430+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14311431
_LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
14321432
return __tree_.__equal_range_multi(__k);
14331433
}
1434-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1434+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14351435
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
14361436
return __tree_.__equal_range_multi(__k);
14371437
}
@@ -1959,27 +1959,27 @@ public:
19591959
_LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
19601960
_LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
19611961
#if _LIBCPP_STD_VER >= 14
1962-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1962+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19631963
_LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
19641964
return __tree_.find(__k);
19651965
}
1966-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1966+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19671967
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
19681968
return __tree_.find(__k);
19691969
}
19701970
#endif
19711971

19721972
_LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
19731973
#if _LIBCPP_STD_VER >= 14
1974-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1974+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19751975
_LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
19761976
return __tree_.__count_multi(__k);
19771977
}
19781978
#endif
19791979

19801980
#if _LIBCPP_STD_VER >= 20
19811981
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1982-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1982+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19831983
_LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
19841984
return find(__k) != end();
19851985
}
@@ -1988,12 +1988,12 @@ public:
19881988
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
19891989
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
19901990
#if _LIBCPP_STD_VER >= 14
1991-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1991+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19921992
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
19931993
return __tree_.lower_bound(__k);
19941994
}
19951995

1996-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1996+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19971997
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
19981998
return __tree_.lower_bound(__k);
19991999
}
@@ -2002,11 +2002,11 @@ public:
20022002
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
20032003
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
20042004
#if _LIBCPP_STD_VER >= 14
2005-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2005+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20062006
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
20072007
return __tree_.upper_bound(__k);
20082008
}
2009-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2009+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20102010
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
20112011
return __tree_.upper_bound(__k);
20122012
}
@@ -2019,11 +2019,11 @@ public:
20192019
return __tree_.__equal_range_multi(__k);
20202020
}
20212021
#if _LIBCPP_STD_VER >= 14
2022-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2022+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20232023
_LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
20242024
return __tree_.__equal_range_multi(__k);
20252025
}
2026-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2026+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20272027
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
20282028
return __tree_.__equal_range_multi(__k);
20292029
}

libcxx/include/set

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -825,27 +825,27 @@ public:
825825
_LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
826826
_LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
827827
#if _LIBCPP_STD_VER >= 14
828-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
828+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
829829
_LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
830830
return __tree_.find(__k);
831831
}
832-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
832+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
833833
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
834834
return __tree_.find(__k);
835835
}
836836
#endif
837837

838838
_LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
839839
#if _LIBCPP_STD_VER >= 14
840-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
840+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
841841
_LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
842842
return __tree_.__count_multi(__k);
843843
}
844844
#endif
845845

846846
#if _LIBCPP_STD_VER >= 20
847847
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
848-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
848+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
849849
_LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
850850
return find(__k) != end();
851851
}
@@ -854,12 +854,12 @@ public:
854854
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
855855
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
856856
#if _LIBCPP_STD_VER >= 14
857-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
857+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
858858
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
859859
return __tree_.lower_bound(__k);
860860
}
861861

862-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
862+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
863863
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
864864
return __tree_.lower_bound(__k);
865865
}
@@ -868,11 +868,11 @@ public:
868868
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
869869
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
870870
#if _LIBCPP_STD_VER >= 14
871-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
871+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
872872
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
873873
return __tree_.upper_bound(__k);
874874
}
875-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
875+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
876876
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
877877
return __tree_.upper_bound(__k);
878878
}
@@ -885,11 +885,11 @@ public:
885885
return __tree_.__equal_range_unique(__k);
886886
}
887887
#if _LIBCPP_STD_VER >= 14
888-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
888+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
889889
_LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
890890
return __tree_.__equal_range_multi(__k);
891891
}
892-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
892+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
893893
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
894894
return __tree_.__equal_range_multi(__k);
895895
}
@@ -1283,27 +1283,27 @@ public:
12831283
_LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
12841284
_LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
12851285
#if _LIBCPP_STD_VER >= 14
1286-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1286+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12871287
_LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
12881288
return __tree_.find(__k);
12891289
}
1290-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1290+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12911291
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
12921292
return __tree_.find(__k);
12931293
}
12941294
#endif
12951295

12961296
_LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
12971297
#if _LIBCPP_STD_VER >= 14
1298-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1298+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12991299
_LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
13001300
return __tree_.__count_multi(__k);
13011301
}
13021302
#endif
13031303

13041304
#if _LIBCPP_STD_VER >= 20
13051305
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1306-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1306+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13071307
_LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
13081308
return find(__k) != end();
13091309
}
@@ -1312,12 +1312,12 @@ public:
13121312
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
13131313
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
13141314
#if _LIBCPP_STD_VER >= 14
1315-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1315+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13161316
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
13171317
return __tree_.lower_bound(__k);
13181318
}
13191319

1320-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1320+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13211321
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
13221322
return __tree_.lower_bound(__k);
13231323
}
@@ -1326,11 +1326,11 @@ public:
13261326
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
13271327
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
13281328
#if _LIBCPP_STD_VER >= 14
1329-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1329+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13301330
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
13311331
return __tree_.upper_bound(__k);
13321332
}
1333-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1333+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13341334
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
13351335
return __tree_.upper_bound(__k);
13361336
}
@@ -1343,11 +1343,11 @@ public:
13431343
return __tree_.__equal_range_multi(__k);
13441344
}
13451345
#if _LIBCPP_STD_VER >= 14
1346-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1346+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13471347
_LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
13481348
return __tree_.__equal_range_multi(__k);
13491349
}
1350-
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1350+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13511351
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
13521352
return __tree_.__equal_range_multi(__k);
13531353
}

0 commit comments

Comments
 (0)