[llvm] [ADT] Document C++20 migration path for llvm::is_detected (PR #164363)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 20 22:58:57 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/164363

The C++20 standard has adopted concepts and requires clauses as a
superior alternative to std::is_detected.

This patch adds a comment for llvm::is_detected to document this
relationship.  The utility is kept in STLForwardCompat.h to serve as a
marker to migrate usages of llvm::is_detected to concepts and
requires clauses when the codebase adopts C++20.


>From b1fa9d0e82548a9000e0426463e77ca78d75900a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 20 Oct 2025 13:07:37 -0700
Subject: [PATCH] [ADT] Document C++20 migration path for llvm::is_detected

The C++20 standard has adopted concepts and requires clauses as a
superior alternative to std::is_detected.

This patch adds a comment for llvm::is_detected to document this
relationship.  The utility is kept in STLForwardCompat.h to serve as a
marker to migrate usages of llvm::is_detected to concepts and
requires clauses when the codebase adopts C++20.
---
 llvm/include/llvm/ADT/STLForwardCompat.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h b/llvm/include/llvm/ADT/STLForwardCompat.h
index 0e9bd2d455965..9c81981534506 100644
--- a/llvm/include/llvm/ADT/STLForwardCompat.h
+++ b/llvm/include/llvm/ADT/STLForwardCompat.h
@@ -115,6 +115,13 @@ struct detector<std::void_t<Op<Args...>>, Op, Args...> {
 ///   using has_copy_assign_t = decltype(std::declval<T&>()
 ///                                                 = std::declval<const T&>());
 ///   bool fooHasCopyAssign = is_detected<has_copy_assign_t, FooClass>::value;
+///
+/// NOTE: The C++20 standard has adopted concepts and requires clauses as a
+/// superior alternative to std::is_detected.
+///
+/// This utility is placed in STLForwardCompat.h as a reminder
+/// to migrate usages of llvm::is_detected to concepts and 'requires'
+/// clauses when the codebase adopts C++20.
 template <template <class...> class Op, class... Args>
 using is_detected = typename detail::detector<void, Op, Args...>::value_t;
 



More information about the llvm-commits mailing list