1. when a placement new (New at a specific position) is declared in the class, it accepts other variables except STD: size_t as parameters, A placement delete must also be declared and its parameters are the same as those of placement new to get a corresponding relationship, in this way, when the memory allocation fails, the C ++ compiler will call the placement delete that matches the placement new to return the memory.
Note: Placement Delete is called only when an exception occurs in the "Constructor triggered with the call to placement New". It is not called when you delete an existing pointer.
2. Avoid using the class-specific new to cover up other new types that the customer expects, such as the general version of new or the new in its base class. The method is to use the using declarative in the appropriate scope.
By default, C ++ provides three types of operator new in the global scope:
void * operator New (STD: size_t) throw (STD: bad_alloc); // normal New void * operator New (STD: size_t, void *) throw (); // placement new void * operator New (STD: size_t, const STD: nothrow_t &) throw (); // nothrow new
If the exclusive operator new is declared in the class, the above version is concealed. In general, these functions should be guaranteed to be available outside the class, and the pair operator new and operator Delete should be declared at the same time. You can declare a base class that contains all the above functions and their corresponding operator Delete functions. You can define a class to inherit the base class and use the using declarative method to obtain the standard form, so that it does not conflict with the custom version.