Skip to content

Commit 8cb03a0

Browse files
authored
[libc++][NFC] Refactor __is_allocator to be a variable template (#159584)
1 parent b5bb50d commit 8cb03a0

File tree

19 files changed

+232
-246
lines changed

19 files changed

+232
-246
lines changed

libcxx/include/__flat_map/flat_map.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,7 @@ class flat_map {
11251125
};
11261126

11271127
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
1128-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1129-
!__is_allocator<_MappedContainer>::value &&
1128+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
11301129
is_invocable_v<const _Compare&,
11311130
const typename _KeyContainer::value_type&,
11321131
const typename _KeyContainer::value_type&>)
@@ -1139,7 +1138,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare())
11391138

11401139
template <class _KeyContainer, class _MappedContainer, class _Allocator>
11411140
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
1142-
!__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
1141+
!__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
11431142
flat_map(_KeyContainer, _MappedContainer, _Allocator)
11441143
-> flat_map<typename _KeyContainer::value_type,
11451144
typename _MappedContainer::value_type,
@@ -1148,9 +1147,8 @@ flat_map(_KeyContainer, _MappedContainer, _Allocator)
11481147
_MappedContainer>;
11491148

11501149
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
1151-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1152-
!__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
1153-
uses_allocator_v<_MappedContainer, _Allocator> &&
1150+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
1151+
uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
11541152
is_invocable_v<const _Compare&,
11551153
const typename _KeyContainer::value_type&,
11561154
const typename _KeyContainer::value_type&>)
@@ -1162,8 +1160,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator)
11621160
_MappedContainer>;
11631161

11641162
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
1165-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1166-
!__is_allocator<_MappedContainer>::value &&
1163+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
11671164
is_invocable_v<const _Compare&,
11681165
const typename _KeyContainer::value_type&,
11691166
const typename _KeyContainer::value_type&>)
@@ -1176,7 +1173,7 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare()
11761173

11771174
template <class _KeyContainer, class _MappedContainer, class _Allocator>
11781175
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
1179-
!__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
1176+
!__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
11801177
flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator)
11811178
-> flat_map<typename _KeyContainer::value_type,
11821179
typename _MappedContainer::value_type,
@@ -1185,9 +1182,8 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator)
11851182
_MappedContainer>;
11861183

11871184
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
1188-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1189-
!__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
1190-
uses_allocator_v<_MappedContainer, _Allocator> &&
1185+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
1186+
uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
11911187
is_invocable_v<const _Compare&,
11921188
const typename _KeyContainer::value_type&,
11931189
const typename _KeyContainer::value_type&>)
@@ -1199,27 +1195,27 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator)
11991195
_MappedContainer>;
12001196

12011197
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1202-
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1198+
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
12031199
flat_map(_InputIterator, _InputIterator, _Compare = _Compare())
12041200
-> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
12051201

12061202
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1207-
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1203+
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
12081204
flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
12091205
-> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
12101206

12111207
template <ranges::input_range _Range,
12121208
class _Compare = less<__range_key_type<_Range>>,
12131209
class _Allocator = allocator<byte>,
1214-
class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
1210+
class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>>
12151211
flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map<
12161212
__range_key_type<_Range>,
12171213
__range_mapped_type<_Range>,
12181214
_Compare,
12191215
vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
12201216
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
12211217

1222-
template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
1218+
template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>>
12231219
flat_map(from_range_t, _Range&&, _Allocator) -> flat_map<
12241220
__range_key_type<_Range>,
12251221
__range_mapped_type<_Range>,
@@ -1228,11 +1224,11 @@ flat_map(from_range_t, _Range&&, _Allocator) -> flat_map<
12281224
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
12291225

12301226
template <class _Key, class _Tp, class _Compare = less<_Key>>
1231-
requires(!__is_allocator<_Compare>::value)
1227+
requires(!__is_allocator_v<_Compare>)
12321228
flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
12331229

12341230
template <class _Key, class _Tp, class _Compare = less<_Key>>
1235-
requires(!__is_allocator<_Compare>::value)
1231+
requires(!__is_allocator_v<_Compare>)
12361232
flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
12371233

12381234
template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator>

libcxx/include/__flat_map/flat_multimap.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,7 @@ class flat_multimap {
928928
};
929929

930930
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
931-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
932-
!__is_allocator<_MappedContainer>::value &&
931+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
933932
is_invocable_v<const _Compare&,
934933
const typename _KeyContainer::value_type&,
935934
const typename _KeyContainer::value_type&>)
@@ -942,7 +941,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare())
942941

943942
template <class _KeyContainer, class _MappedContainer, class _Allocator>
944943
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
945-
!__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
944+
!__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
946945
flat_multimap(_KeyContainer, _MappedContainer, _Allocator)
947946
-> flat_multimap<typename _KeyContainer::value_type,
948947
typename _MappedContainer::value_type,
@@ -951,9 +950,8 @@ flat_multimap(_KeyContainer, _MappedContainer, _Allocator)
951950
_MappedContainer>;
952951

953952
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
954-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
955-
!__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
956-
uses_allocator_v<_MappedContainer, _Allocator> &&
953+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
954+
uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
957955
is_invocable_v<const _Compare&,
958956
const typename _KeyContainer::value_type&,
959957
const typename _KeyContainer::value_type&>)
@@ -965,8 +963,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator)
965963
_MappedContainer>;
966964

967965
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
968-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
969-
!__is_allocator<_MappedContainer>::value &&
966+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
970967
is_invocable_v<const _Compare&,
971968
const typename _KeyContainer::value_type&,
972969
const typename _KeyContainer::value_type&>)
@@ -979,7 +976,7 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _
979976

980977
template <class _KeyContainer, class _MappedContainer, class _Allocator>
981978
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
982-
!__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
979+
!__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
983980
flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator)
984981
-> flat_multimap<typename _KeyContainer::value_type,
985982
typename _MappedContainer::value_type,
@@ -988,9 +985,8 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator)
988985
_MappedContainer>;
989986

990987
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
991-
requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
992-
!__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
993-
uses_allocator_v<_MappedContainer, _Allocator> &&
988+
requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
989+
uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
994990
is_invocable_v<const _Compare&,
995991
const typename _KeyContainer::value_type&,
996992
const typename _KeyContainer::value_type&>)
@@ -1002,27 +998,27 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _A
1002998
_MappedContainer>;
1003999

10041000
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1005-
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1001+
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
10061002
flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare())
10071003
-> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
10081004

10091005
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1010-
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1006+
requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
10111007
flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
10121008
-> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
10131009

10141010
template <ranges::input_range _Range,
10151011
class _Compare = less<__range_key_type<_Range>>,
10161012
class _Allocator = allocator<byte>,
1017-
class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
1013+
class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>>
10181014
flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap<
10191015
__range_key_type<_Range>,
10201016
__range_mapped_type<_Range>,
10211017
_Compare,
10221018
vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
10231019
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
10241020

1025-
template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
1021+
template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>>
10261022
flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap<
10271023
__range_key_type<_Range>,
10281024
__range_mapped_type<_Range>,
@@ -1031,11 +1027,11 @@ flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap<
10311027
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
10321028

10331029
template <class _Key, class _Tp, class _Compare = less<_Key>>
1034-
requires(!__is_allocator<_Compare>::value)
1030+
requires(!__is_allocator_v<_Compare>)
10351031
flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>;
10361032

10371033
template <class _Key, class _Tp, class _Compare = less<_Key>>
1038-
requires(!__is_allocator<_Compare>::value)
1034+
requires(!__is_allocator_v<_Compare>)
10391035
flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare())
10401036
-> flat_multimap<_Key, _Tp, _Compare>;
10411037

0 commit comments

Comments
 (0)