[llvm] [Support] Use llvm::is_detected (NFC) (PR #158504)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 14 12:13:27 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
This patch uses llvm::is_detected to replace the old SFINAE-based
approach.
---
Full diff: https://github.com/llvm/llvm-project/pull/158504.diff
1 Files Affected:
- (modified) llvm/include/llvm/Support/FormatVariadicDetails.h (+3-6)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/158504
More information about the llvm-commits
mailing list