[libc-commits] [libc] [libc] Implement cpp::unique_ptr utility (PR #206701)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Wed Jul 1 00:49:42 PDT 2026


================
@@ -0,0 +1,214 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Standalone implementation of std::unique_ptr.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UNIQUE_PTR_H
+#define LLVM_LIBC_SRC___SUPPORT_CPP_UNIQUE_PTR_H
+
+#include "src/__support/CPP/new.h"
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/CPP/utility.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace cpp {
+
+/// A wrapper for deleting objects by default.
+template <typename T> struct default_delete {
+  LIBC_INLINE constexpr default_delete() = default;
+
+  template <typename U, typename = typename enable_if<
+                            is_convertible<U *, T *>::value>::type>
----------------
labath wrote:

This is somewhat shorter and more consistent with the rest of the codebase.

```suggestion
  template <typename U, typename = typename enable_if_t<
                            is_convertible_v<U *, T *>>>
```


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


More information about the libc-commits mailing list