@@ -2129,21 +2129,32 @@ object that overloads ``operator&``.
2129
2129
``__builtin_operator_new `` and ``__builtin_operator_delete ``
2130
2130
------------------------------------------------------------
2131
2131
2132
- ``__builtin_operator_new `` allocates memory just like a non-placement non-class
2133
- *new-expression *. This is exactly like directly calling the normal
2134
- non-placement ``::operator new ``, except that it allows certain optimizations
2132
+ A call to ``__builtin_operator_new(args) `` is exactly the same as a call to
2133
+ ``::operator new(args) ``, except that it allows certain optimizations
2135
2134
that the C++ standard does not permit for a direct function call to
2136
2135
``::operator new `` (in particular, removing ``new `` / ``delete `` pairs and
2137
- merging allocations).
2136
+ merging allocations), and that the call is required to resolve to a
2137
+ `replaceable global allocation function
2138
+ <https://en.cppreference.com/w/cpp/memory/new/operator_new> `_.
2138
2139
2139
- Likewise, ``__builtin_operator_delete `` deallocates memory just like a
2140
- non-class *delete-expression *, and is exactly like directly calling the normal
2141
- ``::operator delete ``, except that it permits optimizations. Only the unsized
2142
- form of ``__builtin_operator_delete `` is currently available.
2140
+ Likewise, ``__builtin_operator_delete `` is exactly the same as a call to
2141
+ ``::operator delete(args) ``, except that it permits optimizations
2142
+ and that the call is required to resolve to a
2143
+ `replaceable global deallocation function
2144
+ <https://en.cppreference.com/w/cpp/memory/new/operator_delete> `_.
2143
2145
2144
2146
These builtins are intended for use in the implementation of ``std::allocator ``
2145
2147
and other similar allocation libraries, and are only available in C++.
2146
2148
2149
+ Query for this feature with ``__has_builtin(__builtin_operator_new) `` or
2150
+ ``__has_builtin(__builtin_operator_delete) ``:
2151
+
2152
+ * If the value is at least ``201802L ``, the builtins behave as described above.
2153
+
2154
+ * If the value is non-zero, the builtins may not support calling arbitrary
2155
+ replaceable global (de)allocation functions, but do support calling at least
2156
+ ``::operator new(size_t) `` and ``::operator delete(void*) ``.
2157
+
2147
2158
``__builtin_preserve_access_index ``
2148
2159
-----------------------------------
2149
2160
0 commit comments