[llvm] [Support] Use llvm::is_detected (NFC) (PR #158504)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 14 12:12:56 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/158504
This patch uses llvm::is_detected to replace the old SFINAE-based
approach.
>From 812fb35ea44905810f1cbb0f4322fca4499b4f26 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 14 Sep 2025 00:38:01 -0700
Subject: [PATCH] [Support] Use llvm::is_detected (NFC)
This patch uses llvm::is_detected to replace the old SFINAE-based
approach.
---
llvm/include/llvm/Support/FormatVariadicDetails.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/Support/FormatVariadicDetails.h b/llvm/include/llvm/Support/FormatVariadicDetails.h
index b85a4f6065195..1879a9844030c 100644
--- a/llvm/include/llvm/Support/FormatVariadicDetails.h
+++ b/llvm/include/llvm/Support/FormatVariadicDetails.h
@@ -66,13 +66,10 @@ template <class T> class has_FormatProvider {
typedef void (*Signature_format)(const Decayed &, llvm::raw_ostream &,
StringRef);
- template <typename U>
- static char test(SameType<Signature_format, &U::format> *);
-
- template <typename U> static double test(...);
+ template <typename U> using check = SameType<Signature_format, &U::format>;
- static bool const value =
- (sizeof(test<llvm::format_provider<Decayed>>(nullptr)) == 1);
+ static constexpr bool value =
+ llvm::is_detected<check, llvm::format_provider<Decayed>>::value;
};
// Test if raw_ostream& << T -> raw_ostream& is findable via ADL.
More information about the llvm-commits
mailing list