[llvm] [ADT] Use std::conditional_t to simplify ilist_select_iterator_type (NFC) (PR #159240)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 22:12:59 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

Without this patch, ilist_select_iterator_type uses a boolean template
parameter to select one of two types.  This patch converts that to
std::conditional_t, which is simpler than the two-class solution.


---
Full diff: https://github.com/llvm/llvm-project/pull/159240.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/ilist_node.h (+4-8) 


``````````diff
diff --git a/llvm/include/llvm/ADT/ilist_node.h b/llvm/include/llvm/ADT/ilist_node.h
index 67384546a9275..8d78d5dbbda44 100644
--- a/llvm/include/llvm/ADT/ilist_node.h
+++ b/llvm/include/llvm/ADT/ilist_node.h
@@ -52,14 +52,10 @@ template <class OptionsT> class ilist_sentinel;
 
 // Selector for which iterator type to pick given the iterator-bits node option.
 template <bool use_iterator_bits, typename Opts, bool arg1, bool arg2>
-class ilist_select_iterator_type {
-public:
-  using type = ilist_iterator<Opts, arg1, arg2>;
-};
-template <typename Opts, bool arg1, bool arg2>
-class ilist_select_iterator_type<true, Opts, arg1, arg2> {
-public:
-  using type = ilist_iterator_w_bits<Opts, arg1, arg2>;
+struct ilist_select_iterator_type {
+  using type = std::conditional_t<use_iterator_bits,
+                                  ilist_iterator_w_bits<Opts, arg1, arg2>,
+                                  ilist_iterator<Opts, arg1, arg2>>;
 };
 
 /// Implementation for an ilist node.

``````````

</details>


https://github.com/llvm/llvm-project/pull/159240


More information about the llvm-commits mailing list