Skip to content

Commit 3a1298b

Browse files
authored
[libc++][NFC] Replace typedefs with using declarations (#156009)
We've done quite a bit of refactoring recently in `<__tree>`. This patch finishes up replacing typedefs with using declarations. As a side-effect, this also adds some `_LIBCPP_NODEBUG` annotations, since the clang-tidy check catches these now.
1 parent f8faf23 commit 3a1298b

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

libcxx/include/__tree

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ private:
551551
template <class _Pointer>
552552
class __tree_end_node {
553553
public:
554-
typedef _Pointer pointer;
554+
using pointer = _Pointer;
555555
pointer __left_;
556556

557557
_LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {}
@@ -595,11 +595,11 @@ public:
595595

596596
template <class _Allocator>
597597
class __tree_node_destructor {
598-
typedef _Allocator allocator_type;
599-
typedef allocator_traits<allocator_type> __alloc_traits;
598+
using allocator_type = _Allocator;
599+
using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
600600

601601
public:
602-
typedef typename __alloc_traits::pointer pointer;
602+
using pointer = typename __alloc_traits::pointer;
603603

604604
private:
605605
allocator_type& __na_;
@@ -636,10 +636,11 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> :
636636

637637
template <class _Tp, class _NodePtr, class _DiffType>
638638
class __tree_iterator {
639-
typedef __tree_node_types<_NodePtr> _NodeTypes;
640-
typedef _NodePtr __node_pointer;
641-
typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
642-
typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
639+
using _NodeTypes _LIBCPP_NODEBUG = __tree_node_types<_NodePtr>;
640+
// NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing
641+
using __node_pointer = _NodePtr;
642+
using __node_base_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__node_base_pointer;
643+
using __end_node_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__end_node_pointer;
643644

644645
__end_node_pointer __ptr_;
645646

@@ -696,11 +697,11 @@ private:
696697

697698
template <class _Tp, class _NodePtr, class _DiffType>
698699
class __tree_const_iterator {
699-
typedef __tree_node_types<_NodePtr> _NodeTypes;
700+
using _NodeTypes _LIBCPP_NODEBUG = __tree_node_types<_NodePtr>;
700701
// NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing
701-
using __node_pointer = _NodePtr;
702-
typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
703-
typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
702+
using __node_pointer = _NodePtr;
703+
using __node_base_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__node_base_pointer;
704+
using __end_node_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__end_node_pointer;
704705

705706
__end_node_pointer __ptr_;
706707

@@ -769,21 +770,20 @@ int __diagnose_non_const_comparator();
769770
template <class _Tp, class _Compare, class _Allocator>
770771
class __tree {
771772
public:
772-
using value_type = __get_node_value_type_t<_Tp>;
773-
typedef _Compare value_compare;
774-
typedef _Allocator allocator_type;
773+
using value_type = __get_node_value_type_t<_Tp>;
774+
using value_compare = _Compare;
775+
using allocator_type = _Allocator;
775776

776777
private:
777-
typedef allocator_traits<allocator_type> __alloc_traits;
778-
using key_type = __get_tree_key_type_t<_Tp>;
778+
using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
779+
using key_type = __get_tree_key_type_t<_Tp>;
779780

780781
public:
781-
typedef typename __alloc_traits::pointer pointer;
782-
typedef typename __alloc_traits::const_pointer const_pointer;
783-
typedef typename __alloc_traits::size_type size_type;
784-
typedef typename __alloc_traits::difference_type difference_type;
782+
using pointer = typename __alloc_traits::pointer;
783+
using const_pointer = typename __alloc_traits::const_pointer;
784+
using size_type = typename __alloc_traits::size_type;
785+
using difference_type = typename __alloc_traits::difference_type;
785786

786-
public:
787787
using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer;
788788

789789
using __node _LIBCPP_NODEBUG = __tree_node<_Tp, __void_pointer>;
@@ -798,8 +798,8 @@ public:
798798

799799
using __parent_pointer _LIBCPP_NODEBUG = __end_node_pointer; // TODO: Remove this once the uses in <map> are removed
800800

801-
typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
802-
typedef allocator_traits<__node_allocator> __node_traits;
801+
using __node_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __node>;
802+
using __node_traits _LIBCPP_NODEBUG = allocator_traits<__node_allocator>;
803803

804804
// TODO(LLVM 22): Remove this check
805805
#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
@@ -819,8 +819,8 @@ private:
819819
// the pointer using 'pointer_traits'.
820820
static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value,
821821
"Allocator does not rebind pointers in a sane manner.");
822-
typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator;
823-
typedef allocator_traits<__node_base_allocator> __node_base_traits;
822+
using __node_base_allocator _LIBCPP_NODEBUG = __rebind_alloc<__node_traits, __node_base>;
823+
using __node_base_traits _LIBCPP_NODEBUG = allocator_traits<__node_base_allocator>;
824824
static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value,
825825
"Allocator does not rebind pointers in a sane manner.");
826826

@@ -857,8 +857,8 @@ public:
857857
return std::addressof(__end_node()->__left_);
858858
}
859859

860-
typedef __tree_iterator<_Tp, __node_pointer, difference_type> iterator;
861-
typedef __tree_const_iterator<_Tp, __node_pointer, difference_type> const_iterator;
860+
using iterator = __tree_iterator<_Tp, __node_pointer, difference_type>;
861+
using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>;
862862

863863
_LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
864864
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);
@@ -1117,8 +1117,8 @@ public:
11171117
template <class _Key>
11181118
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;
11191119

1120-
typedef __tree_node_destructor<__node_allocator> _Dp;
1121-
typedef unique_ptr<__node, _Dp> __node_holder;
1120+
using _Dp _LIBCPP_NODEBUG = __tree_node_destructor<__node_allocator>;
1121+
using __node_holder _LIBCPP_NODEBUG = unique_ptr<__node, _Dp>;
11221122

11231123
_LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;
11241124

@@ -1411,8 +1411,8 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
14111411
template <class _Tp, class _Compare, class _Allocator>
14121412
template <class _ForwardIterator>
14131413
void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {
1414-
typedef iterator_traits<_ForwardIterator> _ITraits;
1415-
typedef typename _ITraits::value_type _ItValueType;
1414+
using _ITraits = iterator_traits<_ForwardIterator>;
1415+
using _ItValueType = typename _ITraits::value_type;
14161416
static_assert(
14171417
is_same<_ItValueType, value_type>::value, "__assign_unique may only be called with the containers value type");
14181418
static_assert(
@@ -1431,8 +1431,8 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first
14311431
template <class _Tp, class _Compare, class _Allocator>
14321432
template <class _InputIterator>
14331433
void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) {
1434-
typedef iterator_traits<_InputIterator> _ITraits;
1435-
typedef typename _ITraits::value_type _ItValueType;
1434+
using _ITraits = iterator_traits<_InputIterator>;
1435+
using _ItValueType = typename _ITraits::value_type;
14361436
static_assert(
14371437
is_same<_ItValueType, value_type>::value, "__assign_multi may only be called with the containers value_type");
14381438
if (__size_ != 0) {
@@ -2121,7 +2121,7 @@ template <class _Tp, class _Compare, class _Allocator>
21212121
template <class _Key>
21222122
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
21232123
__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
2124-
typedef pair<iterator, iterator> _Pp;
2124+
using _Pp = pair<iterator, iterator>;
21252125
__end_node_pointer __result = __end_node();
21262126
__node_pointer __rt = __root();
21272127
while (__rt != nullptr) {
@@ -2143,7 +2143,7 @@ template <class _Key>
21432143
pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
21442144
typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
21452145
__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
2146-
typedef pair<const_iterator, const_iterator> _Pp;
2146+
using _Pp = pair<const_iterator, const_iterator>;
21472147
__end_node_pointer __result = __end_node();
21482148
__node_pointer __rt = __root();
21492149
while (__rt != nullptr) {
@@ -2165,7 +2165,7 @@ template <class _Tp, class _Compare, class _Allocator>
21652165
template <class _Key>
21662166
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
21672167
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
2168-
typedef pair<iterator, iterator> _Pp;
2168+
using _Pp = pair<iterator, iterator>;
21692169
__end_node_pointer __result = __end_node();
21702170
__node_pointer __rt = __root();
21712171
while (__rt != nullptr) {
@@ -2186,7 +2186,7 @@ template <class _Key>
21862186
pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
21872187
typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
21882188
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
2189-
typedef pair<const_iterator, const_iterator> _Pp;
2189+
using _Pp = pair<const_iterator, const_iterator>;
21902190
__end_node_pointer __result = __end_node();
21912191
__node_pointer __rt = __root();
21922192
while (__rt != nullptr) {

0 commit comments

Comments
 (0)