[clang] [clang] Update diagnostics and documentation for type aware allocators (PR #148576)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 14 18:07:12 PDT 2025
================
@@ -0,0 +1,155 @@
+=========================
+C++ Type Aware Allocators
+=========================
+
+.. contents::
+ :local:
+
+Introduction
+============
+
+Clang includes an implementation of P2719 "Type-aware allocation and deallocation
+functions".
+
+This is a feature that extends the semantics of `new`, `new[]`, `delete` and
+`delete[]` operators to expose the type being allocated to the operator. This
+can be used to customize allocation of types without needing to modify the
+type declaration, or via template definitions fully generic type aware
+allocators.
+
+P2719 introduces a type-identity tag as valid parameter type for all allocation
+operators. This tag is a default initialized value of type `std::type_identity<T>`
+where T is the type being allocated or deallocated. Unlike the other placement
+arguments this tag is passed as the first parameter to the operator.
+
+The most basic use case is as follows
+
+.. code-block:: c++
+
+ #include <new>
+ #include <type_identity>
----------------
zwuis wrote:
`<type_traits>`
https://github.com/llvm/llvm-project/pull/148576
More information about the cfe-commits
mailing list