[llvm] [ADT] Use std::conditional_t to simplify ilist_select_iterator_type (NFC) (PR #159240)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 22:12:26 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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.
>From 19fd833caf1f95f704d51eec5e2d64ddd74ae818 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 15 Sep 2025 00:01:03 -0700
Subject: [PATCH] [ADT] Use std::conditional_t to simplify
ilist_select_iterator_type (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.
---
llvm/include/llvm/ADT/ilist_node.h | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
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