[libcxx-commits] [libcxx] [libc++] Merge is_{, un}bounded_array.h into is_array.h (PR #167479)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 11 01:31:14 PST 2025


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/167479

These headers are incredibly simple and closely related, so this merges them into a single one.


>From 65a900a032643f6489a392c77621e37e5f0bc60f Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 11 Nov 2025 10:30:31 +0100
Subject: [PATCH] [libc++] Merge is_{,un}bounded_array.h into is_array.h

---
 libcxx/include/CMakeLists.txt                 |  3 --
 libcxx/include/__memory/shared_ptr.h          |  2 -
 .../__memory/uninitialized_algorithms.h       |  1 -
 libcxx/include/__memory/unique_ptr.h          |  2 -
 libcxx/include/__type_traits/is_array.h       | 26 +++++++++++++
 .../include/__type_traits/is_bounded_array.h  | 36 ------------------
 .../__type_traits/is_unbounded_array.h        | 38 -------------------
 libcxx/include/module.modulemap.in            |  8 ----
 libcxx/include/optional                       |  1 -
 libcxx/include/type_traits                    |  2 -
 10 files changed, 26 insertions(+), 93 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/is_bounded_array.h
 delete mode 100644 libcxx/include/__type_traits/is_unbounded_array.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 3845ec8376794..8be334244416e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -822,7 +822,6 @@ set(files
   __type_traits/is_array.h
   __type_traits/is_assignable.h
   __type_traits/is_base_of.h
-  __type_traits/is_bounded_array.h
   __type_traits/is_callable.h
   __type_traits/is_char_like_type.h
   __type_traits/is_class.h
@@ -873,7 +872,6 @@ set(files
   __type_traits/is_trivially_destructible.h
   __type_traits/is_trivially_lexicographically_comparable.h
   __type_traits/is_trivially_relocatable.h
-  __type_traits/is_unbounded_array.h
   __type_traits/is_union.h
   __type_traits/is_unqualified.h
   __type_traits/is_unsigned.h
@@ -1472,7 +1470,6 @@ set(files
   __cxx03/__type_traits/is_array.h
   __cxx03/__type_traits/is_assignable.h
   __cxx03/__type_traits/is_base_of.h
-  __cxx03/__type_traits/is_bounded_array.h
   __cxx03/__type_traits/is_callable.h
   __cxx03/__type_traits/is_char_like_type.h
   __cxx03/__type_traits/is_class.h
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index e90db587d2836..959fe3d9567d8 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -41,13 +41,11 @@
 #include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_array.h>
-#include <__type_traits/is_bounded_array.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_convertible.h>
 #include <__type_traits/is_function.h>
 #include <__type_traits/is_reference.h>
 #include <__type_traits/is_same.h>
-#include <__type_traits/is_unbounded_array.h>
 #include <__type_traits/nat.h>
 #include <__type_traits/negation.h>
 #include <__type_traits/remove_cv.h>
diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 34d065dc973e5..9182db4b412e3 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -32,7 +32,6 @@
 #include <__type_traits/is_trivially_assignable.h>
 #include <__type_traits/is_trivially_constructible.h>
 #include <__type_traits/is_trivially_relocatable.h>
-#include <__type_traits/is_unbounded_array.h>
 #include <__type_traits/remove_const.h>
 #include <__type_traits/remove_extent.h>
 #include <__utility/exception_guard.h>
diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index eff24546cdc01..dd77da0208a4d 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -32,7 +32,6 @@
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_array.h>
 #include <__type_traits/is_assignable.h>
-#include <__type_traits/is_bounded_array.h>
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_convertible.h>
@@ -43,7 +42,6 @@
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_swappable.h>
 #include <__type_traits/is_trivially_relocatable.h>
-#include <__type_traits/is_unbounded_array.h>
 #include <__type_traits/is_void.h>
 #include <__type_traits/remove_extent.h>
 #include <__type_traits/type_identity.h>
diff --git a/libcxx/include/__type_traits/is_array.h b/libcxx/include/__type_traits/is_array.h
index e734d1a3043ee..62dd378cec79b 100644
--- a/libcxx/include/__type_traits/is_array.h
+++ b/libcxx/include/__type_traits/is_array.h
@@ -26,6 +26,32 @@ template <class _Tp>
 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp);
 #endif
 
+template <class _Tp>
+inline const bool __is_bounded_array_v = __is_bounded_array(_Tp);
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {};
+
+template <class _Tp>
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
+
+#endif
+
+template <class _Tp>
+inline const bool __is_unbounded_array_v = __is_unbounded_array(_Tp);
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array(_Tp)> {};
+
+template <class _Tp>
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp);
+
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
diff --git a/libcxx/include/__type_traits/is_bounded_array.h b/libcxx/include/__type_traits/is_bounded_array.h
deleted file mode 100644
index 8a41e07aa019b..0000000000000
--- a/libcxx/include/__type_traits/is_bounded_array.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
-#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
-
-#include <__config>
-#include <__type_traits/integral_constant.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-inline const bool __is_bounded_array_v = __is_bounded_array(_Tp);
-
-#if _LIBCPP_STD_VER >= 20
-
-template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {};
-
-template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
-
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
diff --git a/libcxx/include/__type_traits/is_unbounded_array.h b/libcxx/include/__type_traits/is_unbounded_array.h
deleted file mode 100644
index e14809e26a787..0000000000000
--- a/libcxx/include/__type_traits/is_unbounded_array.h
+++ /dev/null
@@ -1,38 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
-#define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
-
-#include <__config>
-#include <__type_traits/integral_constant.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class>
-inline const bool __is_unbounded_array_v = false;
-template <class _Tp>
-inline const bool __is_unbounded_array_v<_Tp[]> = true;
-
-#if _LIBCPP_STD_VER >= 20
-
-template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array_v<_Tp>> {};
-
-template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array_v<_Tp>;
-
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 85fe88afe248c..e8afdb3a05523 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -126,10 +126,6 @@ module std_core [system] {
       header "__type_traits/is_base_of.h"
       export std_core.type_traits.integral_constant
     }
-    module is_bounded_array {
-      header "__type_traits/is_bounded_array.h"
-      export std_core.type_traits.integral_constant
-    }
     module is_callable {
       header "__type_traits/is_callable.h"
       export std_core.type_traits.integral_constant
@@ -327,10 +323,6 @@ module std_core [system] {
       header "__type_traits/is_trivially_relocatable.h"
       export std_core.type_traits.integral_constant
     }
-    module is_unbounded_array {
-      header "__type_traits/is_unbounded_array.h"
-      export std_core.type_traits.integral_constant
-    }
     module is_union {
       header "__type_traits/is_union.h"
       export std_core.type_traits.integral_constant
diff --git a/libcxx/include/optional b/libcxx/include/optional
index ef1bfd3ec44c0..f69199474ce1f 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -238,7 +238,6 @@ namespace std {
 #  include <__type_traits/is_trivially_constructible.h>
 #  include <__type_traits/is_trivially_destructible.h>
 #  include <__type_traits/is_trivially_relocatable.h>
-#  include <__type_traits/is_unbounded_array.h>
 #  include <__type_traits/negation.h>
 #  include <__type_traits/remove_const.h>
 #  include <__type_traits/remove_cv.h>
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index dab0c0640c389..f3e397e4df80c 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -550,9 +550,7 @@ namespace std
 
 #  if _LIBCPP_STD_VER >= 20
 #    include <__type_traits/common_reference.h>
-#    include <__type_traits/is_bounded_array.h>
 #    include <__type_traits/is_constant_evaluated.h>
-#    include <__type_traits/is_unbounded_array.h>
 #    include <__type_traits/type_identity.h>
 #    include <__type_traits/unwrap_ref.h>
 #  endif



More information about the libcxx-commits mailing list