Skip to content

Conversation

kazutakahirata
Copy link
Contributor

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.

…NFC)

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.
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

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 --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.

@kazutakahirata kazutakahirata merged commit 562fe41 into llvm:main Sep 17, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250916_ADT_ilist_select_iterator_type branch September 17, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants