[libcxx-commits] [libcxx] [libc++][test] Move backported algorithms to `libcxx/test/support` (PR #199431)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 24 08:46:35 PDT 2026


https://github.com/frederick-vs-ja created https://github.com/llvm/llvm-project/pull/199431

And namespace `util`. This will make helpers provided more consistently, and potentially allow us to unify test helper namespaces in the future.

>From 2fd7971d29edc951709ab9e0e8f4418ed6fb4b03 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Sun, 24 May 2026 23:42:56 +0800
Subject: [PATCH] [libc++][test] Move backported algorithms to
 `libcxx/test/support`

And namespace `util`. This will make helpers provided more consistently,
and potentially allow us to unify test helper namespaces in the future.
---
 .../destroy.h => support/algorithms.h}         | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
 rename libcxx/test/{std/utilities/memory/specialized.algorithms/destroy.h => support/algorithms.h} (74%)

diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/destroy.h b/libcxx/test/support/algorithms.h
similarity index 74%
rename from libcxx/test/std/utilities/memory/specialized.algorithms/destroy.h
rename to libcxx/test/support/algorithms.h
index e6af0008757c6..83d8b9d5c84d1 100644
--- a/libcxx/test/std/utilities/memory/specialized.algorithms/destroy.h
+++ b/libcxx/test/support/algorithms.h
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_DESTROY_H
-#define LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_DESTROY_H
+#ifndef TEST_SUPPORT_ALGORITHMS_H
+#define TEST_SUPPORT_ALGORITHMS_H
 
 #include <cstddef>
 #include <memory>
@@ -16,7 +16,9 @@
 
 #include "test_macros.h"
 
-namespace backport {
+// This file intends to provide algorithms backported from newer standard revisions.
+
+namespace util {
 
 template <class T, typename std::enable_if<!std::is_array<T>::value, int>::type = 0>
 TEST_CONSTEXPR_CXX20 void destroy_at(T* p) {
@@ -26,22 +28,22 @@ template <class T, typename std::enable_if<std::is_array<T>::value, int>::type =
 TEST_CONSTEXPR_CXX20 void destroy_at(T* p) {
   static_assert(std::extent<T>::value > 0, "must destroy a bounded array");
   for (std::size_t i = 0; i != std::extent<T>::value; ++i)
-    backport::destroy_at(i + *p);
+    util::destroy_at(i + *p);
 }
 
 template <class Iterator>
 TEST_CONSTEXPR_CXX20 void destroy(Iterator first, Iterator last) {
   for (; first != last; ++first)
-    backport::destroy_at(std::addressof(*first));
+    util::destroy_at(std::addressof(*first));
 }
 
 template <class Iterator, class Size>
 TEST_CONSTEXPR_CXX20 Iterator destroy_n(Iterator first, Size n) {
   for (; n > 0; ++first, (void)--n)
-    backport::destroy_at(std::addressof(*first));
+    util::destroy_at(std::addressof(*first));
   return first;
 }
 
-} // namespace backport
+} // namespace util
 
-#endif // LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_DESTROY_H
+#endif // TEST_SUPPORT_ALGORITHMS_H



More information about the libcxx-commits mailing list