From d74eb1985d3ba4f9d07da6f7af05c7e358272599 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 3 Sep 2025 21:52:28 -0700 Subject: [PATCH] [ADT] Simplify TypesAreDistinct with std::conjunction (NFC) This patch uses std::conjunction to succinctly compute "AND" of: - std::negation> - TypesAreDistinct // recursive step This way, we can eliminate the entire "detail" block. --- llvm/include/llvm/ADT/STLExtras.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index b23188cbdadeb..a5c45a21a2401 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -133,15 +133,6 @@ using is_one_of = std::disjunction...>; template using are_base_of = std::conjunction...>; -namespace detail { -template struct TypesAreDistinct; -template -struct TypesAreDistinct - : std::integral_constant::value && - TypesAreDistinct::value> {}; -template struct TypesAreDistinct : std::true_type {}; -} // namespace detail - /// Determine if all types in Ts are distinct. /// /// Useful to statically assert when Ts is intended to describe a non-multi set @@ -151,9 +142,10 @@ template struct TypesAreDistinct : std::true_type {}; /// asserted once per instantiation of a type which requires it. template struct TypesAreDistinct; template <> struct TypesAreDistinct<> : std::true_type {}; -template -struct TypesAreDistinct - : std::integral_constant::value> {}; +template +struct TypesAreDistinct + : std::conjunction>, + TypesAreDistinct> {}; /// Find the first index where a type appears in a list of types. ///