I was discussing doron's answer to this question, and it was said that
[one] will probably find that the C++ standard library defines new to use malloc under the hood.
I'm wondering if this is true. Does the C++ Standard define new
to use malloc
?
Does the C++ standard define new to use malloc?
The C++ Standard (meaning the Standard document that defines the C++ Language) doesn't define operator new
in terms of malloc()
. However, it is plausible that most implementations of the C++ Standard Library use malloc()
to allocate memory.
Per Paragraph 18.6.1.1/4 of the C++11 Standard (about operator new
):
Default behavior
- Executes a loop: Within the loop, the function first attempts to allocate the requested storage. Whether the attempt involves a call to the Standard C library function
malloc
is unspecified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With