[llvm] 562fe41 - [ADT] Use std::conditional_t to simplify ilist_select_iterator_type (NFC) (#159240)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Sep 17 07:09:43 PDT 2025
    
    
  
Author: Kazu Hirata
Date: 2025-09-17T07:09:39-07:00
New Revision: 562fe413e06aa12fc91eb22ca9c7386239f5af4a
URL: https://github.com/llvm/llvm-project/commit/562fe413e06aa12fc91eb22ca9c7386239f5af4a
DIFF: https://github.com/llvm/llvm-project/commit/562fe413e06aa12fc91eb22ca9c7386239f5af4a.diff
LOG: [ADT] Use std::conditional_t to simplify ilist_select_iterator_type (NFC) (#159240)
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.
Added: 
    
Modified: 
    llvm/include/llvm/ADT/ilist_node.h
Removed: 
    
################################################################################
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.
        
    
    
More information about the llvm-commits
mailing list