Skip to content

Commit 1f8e2a4

Browse files
authored
[libc++][NFC] Remove __remove_uncvref (#140531)
The use-case for `__is_same_uncvref` seems rather dubious, since not a single use-cases needed the `remove_cvref_t` to be applied to both of the arguments. Removing the alias makes it clearer what actually happens, since we're not using an internal name anymore and it's clear what the `remove_cvref_t` should apply to.
1 parent 8f6a964 commit 1f8e2a4

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

libcxx/include/__functional/boyer_moore_searcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class boyer_moore_searcher {
123123
template <class _RandomAccessIterator2>
124124
_LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
125125
operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
126-
static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
127-
typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
126+
static_assert(is_same_v<__remove_cvref_t<typename iterator_traits<_RandomAccessIterator1>::value_type>,
127+
__remove_cvref_t<typename iterator_traits<_RandomAccessIterator2>::value_type>>,
128128
"Corpus and Pattern iterators must point to the same type");
129129
if (__first == __last)
130130
return std::make_pair(__last, __last);
@@ -254,8 +254,8 @@ class boyer_moore_horspool_searcher {
254254
template <class _RandomAccessIterator2>
255255
_LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
256256
operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
257-
static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
258-
typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
257+
static_assert(is_same_v<__remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator1>::value_type>,
258+
__remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator2>::value_type>>,
259259
"Corpus and Pattern iterators must point to the same type");
260260
if (__first == __last)
261261
return std::make_pair(__last, __last);

libcxx/include/__functional/reference_wrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <__type_traits/invoke.h>
2020
#include <__type_traits/is_const.h>
2121
#include <__type_traits/is_core_convertible.h>
22+
#include <__type_traits/is_same.h>
2223
#include <__type_traits/remove_cvref.h>
2324
#include <__type_traits/void_t.h>
2425
#include <__utility/declval.h>
@@ -45,7 +46,7 @@ class reference_wrapper : public __weak_result_type<_Tp> {
4546
public:
4647
template <class _Up,
4748
class = __void_t<decltype(__fun(std::declval<_Up>()))>,
48-
__enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, int> = 0>
49+
__enable_if_t<!is_same<__remove_cvref_t<_Up>, reference_wrapper>::value, int> = 0>
4950
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u)
5051
_NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
5152
type& __f = static_cast<_Up&&>(__u);

libcxx/include/__hash_table

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
207207

208208
_LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; }
209209

210-
template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, int> = 0>
210+
template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __node_value_type>::value, int> = 0>
211211
_LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
212212
return __t.__get_value();
213213
}
214214

215-
template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
215+
template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __container_value_type>::value, int> = 0>
216216
_LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
217217
return __t;
218218
}
@@ -856,7 +856,7 @@ public:
856856
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x));
857857
}
858858

859-
template <class _Pp, __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value, int> = 0>
859+
template <class _Pp, __enable_if_t<!is_same<__remove_cvref_t<_Pp>, __container_value_type>::value, int> = 0>
860860
_LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) {
861861
return __emplace_unique(std::forward<_Pp>(__x));
862862
}

libcxx/include/__type_traits/remove_cvref.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
1111

1212
#include <__config>
13-
#include <__type_traits/is_same.h>
1413

1514
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1615
# pragma GCC system_header
@@ -31,9 +30,6 @@ template <class _Tp>
3130
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
3231
#endif // __has_builtin(__remove_cvref)
3332

34-
template <class _Tp, class _Up>
35-
using __is_same_uncvref _LIBCPP_NODEBUG = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >;
36-
3733
#if _LIBCPP_STD_VER >= 20
3834
template <class _Tp>
3935
struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref {

libcxx/include/string

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ public:
11261126

11271127
template <class _Tp,
11281128
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1129-
!__is_same_uncvref<_Tp, basic_string>::value,
1129+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
11301130
int> = 0>
11311131
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
11321132
basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())
@@ -1138,7 +1138,7 @@ public:
11381138

11391139
template <class _Tp,
11401140
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1141-
!__is_same_uncvref<_Tp, basic_string>::value,
1141+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
11421142
int> = 0>
11431143
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {
11441144
__self_view __sv = __t;
@@ -1147,7 +1147,7 @@ public:
11471147

11481148
template <class _Tp,
11491149
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1150-
!__is_same_uncvref<_Tp, basic_string>::value,
1150+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
11511151
int> = 0>
11521152
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
11531153
: __alloc_(__a) {
@@ -1206,7 +1206,7 @@ public:
12061206

12071207
template <class _Tp,
12081208
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1209-
!__is_same_uncvref<_Tp, basic_string>::value,
1209+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
12101210
int> = 0>
12111211
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {
12121212
__self_view __sv = __t;
@@ -1343,7 +1343,7 @@ public:
13431343

13441344
template <class _Tp,
13451345
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1346-
!__is_same_uncvref<_Tp, basic_string >::value,
1346+
!is_same<__remove_cvref_t<_Tp>, basic_string >::value,
13471347
int> = 0>
13481348
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const _Tp& __t) {
13491349
__self_view __sv = __t;
@@ -1372,7 +1372,7 @@ public:
13721372

13731373
template <class _Tp,
13741374
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1375-
!__is_same_uncvref<_Tp, basic_string>::value,
1375+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
13761376
int> = 0>
13771377
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const _Tp& __t) {
13781378
__self_view __sv = __t;
@@ -1383,7 +1383,7 @@ public:
13831383

13841384
template <class _Tp,
13851385
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1386-
!__is_same_uncvref<_Tp, basic_string>::value,
1386+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
13871387
int> = 0>
13881388
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
13891389
append(const _Tp& __t, size_type __pos, size_type __n = npos) {
@@ -1510,7 +1510,7 @@ public:
15101510

15111511
template <class _Tp,
15121512
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1513-
!__is_same_uncvref<_Tp, basic_string>::value,
1513+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
15141514
int> = 0>
15151515
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
15161516
assign(const _Tp& __t, size_type __pos, size_type __n = npos) {
@@ -1580,7 +1580,7 @@ public:
15801580

15811581
template <class _Tp,
15821582
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1583-
!__is_same_uncvref<_Tp, basic_string>::value,
1583+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
15841584
int> = 0>
15851585
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
15861586
insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos) {
@@ -1661,7 +1661,7 @@ public:
16611661

16621662
template <class _Tp,
16631663
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1664-
!__is_same_uncvref<_Tp, basic_string>::value,
1664+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
16651665
int> = 0>
16661666
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
16671667
replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) {
@@ -2006,7 +2006,7 @@ public:
20062006

20072007
template <class _Tp,
20082008
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
2009-
!__is_same_uncvref<_Tp, basic_string>::value,
2009+
!is_same<__remove_cvref_t<_Tp>, basic_string>::value,
20102010
int> = 0>
20112011
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int
20122012
compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const {

libcxx/test/libcxx/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ struct ReferenceWrapper {
254254
static void fun(Type&) noexcept;
255255
static void fun(Type&&) = delete;
256256

257-
template <class Type2,
258-
class = typename std::enable_if<!std::__is_same_uncvref<Type2, ReferenceWrapper>::value>::type>
257+
template <
258+
class Type2,
259+
class = typename std::enable_if<!std::is_same<std::__remove_cvref_t<Type2>, ReferenceWrapper>::value>::type>
259260
constexpr ReferenceWrapper(Type2&& t) noexcept : ptr(&t) {}
260261

261262
constexpr Type& get() const noexcept { return *ptr; }

0 commit comments

Comments
 (0)