4 ms·
It's an operator, and in C++ operators are basically just functions with some syntax sugar because of the extensive overloading. However, C++ doesn't have a si
by tialaramex 5y ago
It's an operator, and in C++ operators are basically just functions with some syntax sugar because of the extensive overloading.
However, C++ doesn't have a single base class, so by making new an operator, it has a default implementation in every type whereas there is nowhere to write a function with that behaviour.
This doesn't matter for malloc because C doesn't have a type hierarchy.
Edited to add: std::make_unique always makes the thing std::make_unique wants to make, you can't overload that for your new type where it should do something else.