[llvm] [llvm] replace static_assert with std::enable_if_t in ilist_node_impl (PR #127722)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 20:54:44 PST 2025


================
@@ -147,9 +149,8 @@ class ilist_node_impl
   ///
   /// This requires sentinel tracking to be explicitly enabled.  Use the
   /// ilist_sentinel_tracking<true> option to get this API.
-  bool isSentinel() const {
-    static_assert(OptionsT::is_sentinel_tracking_explicit,
-                  "Use ilist_sentinel_tracking<true> to enable isSentinel()");
+  template <typename T = OptionsT>
+  std::enable_if_t<T::is_sentinel_tracking_explicit, bool> isSentinel() const {
----------------
MaskRay wrote:

enable_if makes readers confused: is this for some SFINAE. 

Better to use a specific workaround in the body skip the static_assert if 
`defined(_MSC_VER) && !defined(__clang__) && defined(LLVM_BUILD_LLVM_DYLIB)`

https://github.com/llvm/llvm-project/pull/127722


More information about the llvm-commits mailing list