Skip to content

Commit e763364

Browse files
committed
[libc++] Remove __dependent_type
1 parent 0b52b82 commit e763364

File tree

5 files changed

+44
-109
lines changed

5 files changed

+44
-109
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,6 @@ set(files
801801
__type_traits/copy_cvref.h
802802
__type_traits/datasizeof.h
803803
__type_traits/decay.h
804-
__type_traits/dependent_type.h
805804
__type_traits/desugars_to.h
806805
__type_traits/detected_or.h
807806
__type_traits/disjunction.h

libcxx/include/__memory/unique_ptr.h

Lines changed: 40 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <__type_traits/add_reference.h>
2828
#include <__type_traits/common_type.h>
2929
#include <__type_traits/conditional.h>
30-
#include <__type_traits/dependent_type.h>
3130
#include <__type_traits/enable_if.h>
3231
#include <__type_traits/integral_constant.h>
3332
#include <__type_traits/is_array.h>
@@ -46,7 +45,7 @@
4645
#include <__type_traits/is_unbounded_array.h>
4746
#include <__type_traits/is_void.h>
4847
#include <__type_traits/remove_extent.h>
49-
#include <__type_traits/type_identity.h>
48+
#include <__type_traits/remove_reference.h>
5049
#include <__utility/declval.h>
5150
#include <__utility/forward.h>
5251
#include <__utility/move.h>
@@ -98,28 +97,6 @@ inline const bool __is_default_deleter_v = false;
9897
template <class _Tp>
9998
inline const bool __is_default_deleter_v<default_delete<_Tp> > = true;
10099

101-
template <class _Deleter>
102-
struct __unique_ptr_deleter_sfinae {
103-
static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
104-
typedef const _Deleter& __lval_ref_type;
105-
typedef _Deleter&& __good_rval_ref_type;
106-
typedef true_type __enable_rval_overload;
107-
};
108-
109-
template <class _Deleter>
110-
struct __unique_ptr_deleter_sfinae<_Deleter const&> {
111-
typedef const _Deleter& __lval_ref_type;
112-
typedef const _Deleter&& __bad_rval_ref_type;
113-
typedef false_type __enable_rval_overload;
114-
};
115-
116-
template <class _Deleter>
117-
struct __unique_ptr_deleter_sfinae<_Deleter&> {
118-
typedef _Deleter& __lval_ref_type;
119-
typedef _Deleter&& __bad_rval_ref_type;
120-
typedef false_type __enable_rval_overload;
121-
};
122-
123100
#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
124101
# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))
125102
#else
@@ -151,23 +128,9 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
151128
private:
152129
_LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
153130

154-
using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>;
155-
156-
template <bool _Dummy>
157-
using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
158-
159131
template <bool _Dummy>
160-
using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
161-
162-
template <bool _Dummy>
163-
using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
164-
165-
template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
166132
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
167-
__enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
168-
169-
template <class _ArgType>
170-
using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
133+
__enable_if_t<_Dummy && is_default_constructible<deleter_type>::value && !is_pointer<deleter_type>::value>;
171134

172135
template <class _UPtr, class _Up>
173136
using _EnableIfMoveConvertible _LIBCPP_NODEBUG =
@@ -193,20 +156,27 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
193156
: __ptr_(__p),
194157
__deleter_() {}
195158

196-
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
197-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
159+
template <bool _Dummy = true,
160+
__enable_if_t<_Dummy && is_constructible<deleter_type, const deleter_type&>::value, int> = 0>
161+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, const deleter_type& __d) _NOEXCEPT
198162
: __ptr_(__p),
199163
__deleter_(__d) {}
200164

201-
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
202-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
165+
template <bool _Dummy = true,
166+
__enable_if_t<_Dummy && !is_reference<deleter_type>::value &&
167+
is_constructible<deleter_type, deleter_type&&>::value,
168+
int> = 0>
169+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, deleter_type&& __d) _NOEXCEPT
203170
: __ptr_(__p),
204171
__deleter_(std::move(__d)) {
205172
static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
206173
}
207174

208-
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
209-
_LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
175+
template <bool _Dummy = true,
176+
__enable_if_t<_Dummy && is_reference<deleter_type>::value &&
177+
is_constructible<deleter_type, __libcpp_remove_reference_t<deleter_type>&&>::value,
178+
int> = 0>
179+
_LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, __libcpp_remove_reference_t<deleter_type>&& __d) = delete;
210180

211181
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
212182
: __ptr_(__u.release()),
@@ -438,20 +408,9 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
438408
(is_same<pointer, element_type*>::value &&
439409
is_convertible<_FromElem (*)[], element_type (*)[]>::value) > {};
440410

441-
typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
442-
443-
template <bool _Dummy>
444-
using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
445-
446-
template <bool _Dummy>
447-
using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
448-
449411
template <bool _Dummy>
450-
using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
451-
452-
template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
453412
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
454-
__enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
413+
__enable_if_t<_Dummy && is_default_constructible<deleter_type>::value && !is_pointer<deleter_type>::value>;
455414

456415
template <class _ArgType>
457416
using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
@@ -495,42 +454,48 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
495454
__checker_(__size) {}
496455

497456
template <class _Pp,
498-
bool _Dummy = true,
499-
class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
500-
class = _EnableIfPointerConvertible<_Pp> >
501-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, _LValRefType<_Dummy> __deleter) _NOEXCEPT
457+
bool _Dummy = true,
458+
__enable_if_t<_Dummy && is_constructible<deleter_type, const deleter_type&>::value, int> = 0,
459+
class = _EnableIfPointerConvertible<_Pp> >
460+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, const deleter_type& __deleter) _NOEXCEPT
502461
: __ptr_(__ptr),
503462
__deleter_(__deleter) {}
504463

505-
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
506-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __deleter) _NOEXCEPT
464+
template <bool _Dummy = true,
465+
__enable_if_t<_Dummy && is_constructible<deleter_type, const deleter_type&>::value, int> = 0>
466+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, const deleter_type& __deleter) _NOEXCEPT
507467
: __ptr_(nullptr),
508468
__deleter_(__deleter) {}
509469

510470
template <class _Pp,
511-
bool _Dummy = true,
512-
class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
513-
class = _EnableIfPointerConvertible<_Pp> >
514-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
515-
unique_ptr(_Pp __ptr, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
471+
bool _Dummy = true,
472+
__enable_if_t<_Dummy && !is_reference<deleter_type>::value &&
473+
is_constructible<deleter_type, deleter_type&&>::value,
474+
int> = 0,
475+
class = _EnableIfPointerConvertible<_Pp> >
476+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, deleter_type&& __deleter) _NOEXCEPT
516477
: __ptr_(__ptr),
517478
__deleter_(std::move(__deleter)) {
518479
static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
519480
}
520481

521-
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
522-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
523-
unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
482+
template <bool _Dummy = true,
483+
__enable_if_t<_Dummy && !is_reference<deleter_type>::value &&
484+
is_constructible<deleter_type, deleter_type&&>::value,
485+
int> = 0>
486+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, deleter_type&& __deleter) _NOEXCEPT
524487
: __ptr_(nullptr),
525488
__deleter_(std::move(__deleter)) {
526489
static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
527490
}
528491

529492
template <class _Pp,
530-
bool _Dummy = true,
531-
class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
532-
class = _EnableIfPointerConvertible<_Pp> >
533-
_LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete;
493+
bool _Dummy = true,
494+
__enable_if_t<_Dummy && is_reference<deleter_type>::value &&
495+
is_constructible<deleter_type, __libcpp_remove_reference_t<deleter_type>&&>::value,
496+
int> = 0,
497+
class = _EnableIfPointerConvertible<_Pp> >
498+
_LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, __libcpp_remove_reference_t<deleter_type>&& __deleter) = delete;
534499

535500
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
536501
: __ptr_(__u.release()),

libcxx/include/__type_traits/dependent_type.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

libcxx/include/module.modulemap.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ module std_core [system] {
8484
module copy_cvref { header "__type_traits/copy_cvref.h" }
8585
module datasizeof { header "__type_traits/datasizeof.h" }
8686
module decay { header "__type_traits/decay.h" }
87-
module dependent_type { header "__type_traits/dependent_type.h" }
8887
module desugars_to { header "__type_traits/desugars_to.h" }
8988
module detected_or { header "__type_traits/detected_or.h" }
9089
module disjunction { header "__type_traits/disjunction.h" }

libcxx/include/variant

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ namespace std {
235235
# include <__type_traits/conditional.h>
236236
# include <__type_traits/conjunction.h>
237237
# include <__type_traits/decay.h>
238-
# include <__type_traits/dependent_type.h>
239238
# include <__type_traits/enable_if.h>
240239
# include <__type_traits/invoke.h>
241240
# include <__type_traits/is_array.h>
@@ -1174,8 +1173,7 @@ public:
11741173
conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;
11751174
using __replaceable _LIBCPP_NODEBUG = conditional_t<_And<__is_replaceable<_Types>...>::value, variant, void>;
11761175

1177-
template <bool _Dummy = true,
1178-
enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0>
1176+
template <bool _Dummy = true, enable_if_t<_Dummy && is_default_constructible<__first_type>::value, int> = 0>
11791177
_LIBCPP_HIDE_FROM_ABI constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
11801178
: __impl_(in_place_index<0>) {}
11811179

@@ -1290,10 +1288,9 @@ public:
12901288

12911289
_LIBCPP_HIDE_FROM_ABI constexpr size_t index() const noexcept { return __impl_.index(); }
12921290

1293-
template < bool _Dummy = true,
1294-
enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
1295-
__dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
1296-
int> = 0>
1291+
template <
1292+
bool _Dummy = true,
1293+
enable_if_t<_Dummy && __all<(is_move_constructible_v<_Types> && is_swappable_v<_Types>)...>::value, int> = 0>
12971294
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(variant& __that) noexcept(
12981295
__all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) {
12991296
__impl_.__swap(__that.__impl_);

0 commit comments

Comments
 (0)