[llvm] [ADT] Make `is_scoped_enum_v` SFINAE-able (PR #138134)

Vlad Serebrennikov via llvm-commits llvm-commits at lists.llvm.org
Thu May 1 06:52:59 PDT 2025


https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/138134

...in old compilers where `std::underlying_type` is not SFINAE-friendly. Fixes buildbot failure https://lab.llvm.org/buildbot/#/builders/134/builds/17904 caused by #138089. Demo: https://godbolt.org/z/1dj5Ysn8E

>From 31a9c444b5ef6155ec1cdb35d9e659dd60b21dcc Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Thu, 1 May 2025 16:51:38 +0300
Subject: [PATCH] [ADT] Make `is_scoped_enum_v` SFINAE-able

...in old compilers where `std::underlying_type` is not SFINAE-friendly. Fixes buildbot failure https://lab.llvm.org/buildbot/#/builders/134/builds/17904 caused by #138089
---
 llvm/include/llvm/ADT/STLForwardCompat.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h b/llvm/include/llvm/ADT/STLForwardCompat.h
index b8d4babc95fea..c70f4dc29aee0 100644
--- a/llvm/include/llvm/ADT/STLForwardCompat.h
+++ b/llvm/include/llvm/ADT/STLForwardCompat.h
@@ -73,7 +73,8 @@ struct from_range_t {
 };
 inline constexpr from_range_t from_range{};
 
-template <typename T, typename UnderlyingT = std::underlying_type_t<T>>
+template <typename T, typename UnderlyingT = typename std::enable_if_t<
+                          std::is_enum_v<T>, std::underlying_type<T>>::type>
 constexpr bool is_scoped_enum_v =
     std::is_enum_v<T> && !std::is_convertible_v<T, UnderlyingT>;
 



More information about the llvm-commits mailing list