[libcxx-commits] [libcxx] 6f2726d - [libc++] Assume that __array_rank is provided by the compiler (#202511)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 10 01:15:27 PDT 2026
Author: Nikolas Klauser
Date: 2026-06-10T10:15:23+02:00
New Revision: 6f2726dc2c03aa78532d60746cdfdff069033cc6
URL: https://github.com/llvm/llvm-project/commit/6f2726dc2c03aa78532d60746cdfdff069033cc6
DIFF: https://github.com/llvm/llvm-project/commit/6f2726dc2c03aa78532d60746cdfdff069033cc6.diff
LOG: [libc++] Assume that __array_rank is provided by the compiler (#202511)
All compilers we support have `__array_rank`, so we can remove the
preprocessor branch for supporting compilers which don't provide it.
Added:
Modified:
libcxx/include/__type_traits/rank.h
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h
index 5196b62949fa2..2a3f038a3f844 100644
--- a/libcxx/include/__type_traits/rank.h
+++ b/libcxx/include/__type_traits/rank.h
@@ -19,32 +19,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) || \
- (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001)
-
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {};
-#else
-
-template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {};
-
-_LIBCPP_DIAGNOSTIC_PUSH
-# if __has_warning("-Winvalid-specialization")
-_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
-# endif
-template <class _Tp>
-struct rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
-template <class _Tp, size_t _Np>
-struct rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
-_LIBCPP_DIAGNOSTIC_POP
-
-#endif // __has_builtin(__array_rank)
-
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = rank<_Tp>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = __array_rank(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
More information about the libcxx-commits
mailing list