Skip to content

Commit d616013

Browse files
[ADT] Make ilist_select_iterator_type a type alias (NFC) (#160446)
Without this patch, we have: template <bool use_iterator_bits, typename Opts, bool arg1, bool arg2> struct ilist_select_iterator_type { using type = ...; } This means that we must reference "type" with somewhat mouthful: typename ilist_select_iterator_type<...>::type This patch simplifies the reference by making ilist_select_iterator_type a type alias. Now, we always obtain "bool use_iterator_bit" from OptionsT::has_iterator_bits, so this patch folds the logic into the type alias.
1 parent 21ce61b commit d616013

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

llvm/include/llvm/ADT/ilist_node.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ class ilist_iterator_w_bits;
5151
template <class OptionsT> class ilist_sentinel;
5252

5353
// Selector for which iterator type to pick given the iterator-bits node option.
54-
template <bool use_iterator_bits, typename Opts, bool arg1, bool arg2>
55-
struct ilist_select_iterator_type {
56-
using type = std::conditional_t<use_iterator_bits,
57-
ilist_iterator_w_bits<Opts, arg1, arg2>,
58-
ilist_iterator<Opts, arg1, arg2>>;
59-
};
54+
template <class OptionsT, bool IsReverse, bool IsConst>
55+
using ilist_select_iterator_type =
56+
std::conditional_t<OptionsT::has_iterator_bits,
57+
ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>,
58+
ilist_iterator<OptionsT, IsReverse, IsConst>>;
6059

6160
/// Implementation for an ilist node.
6261
///
@@ -91,18 +90,12 @@ class ilist_node_impl
9190
friend class ilist_iterator_w_bits<OptionsT, true, true>;
9291

9392
protected:
94-
using self_iterator =
95-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
96-
false, false>::type;
97-
using const_self_iterator =
98-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
99-
false, true>::type;
93+
using self_iterator = ilist_select_iterator_type<OptionsT, false, false>;
94+
using const_self_iterator = ilist_select_iterator_type<OptionsT, false, true>;
10095
using reverse_self_iterator =
101-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
102-
true, false>::type;
96+
ilist_select_iterator_type<OptionsT, true, false>;
10397
using const_reverse_self_iterator =
104-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
105-
true, true>::type;
98+
ilist_select_iterator_type<OptionsT, true, true>;
10699

107100
ilist_node_impl() = default;
108101

llvm/include/llvm/ADT/simple_ilist.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,11 @@ class simple_ilist
9292
using reference = typename OptionsT::reference;
9393
using const_pointer = typename OptionsT::const_pointer;
9494
using const_reference = typename OptionsT::const_reference;
95-
using iterator =
96-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
97-
false, false>::type;
98-
using const_iterator =
99-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
100-
false, true>::type;
101-
using reverse_iterator =
102-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
103-
true, false>::type;
95+
using iterator = ilist_select_iterator_type<OptionsT, false, false>;
96+
using const_iterator = ilist_select_iterator_type<OptionsT, false, true>;
97+
using reverse_iterator = ilist_select_iterator_type<OptionsT, true, false>;
10498
using const_reverse_iterator =
105-
typename ilist_select_iterator_type<OptionsT::has_iterator_bits, OptionsT,
106-
true, true>::type;
99+
ilist_select_iterator_type<OptionsT, true, true>;
107100
using size_type = size_t;
108101
using difference_type = ptrdiff_t;
109102

0 commit comments

Comments
 (0)