How should I write ISO C++ Standard conformant custom new and delete operators?

Part I This C++ FAQ entry explained why one might want to overload new and delete operators for one’s own class. This present FAQ tries to explain how one does so in a standard-conforming way. Implementing a custom new operator The C++ standard (ยง18.4.1.1) defines operator new as: void* operator new (std::size_t size) throw (std::bad_alloc); … Read more

Is delete[] equal to delete?

Whether this leads to a memory leak, wipes your hard disk, gets you pregnant, makes nasty Nasal Demons chasing you around your apartment, or lets everything work fine with no apparent problems, is undefined. It might be this way with one compiler, and change with another, change with a new compiler version, with each new … Read more

Deleting array elements in JavaScript – delete vs splice

delete will delete the object property, but will not reindex the array or update its length. This makes it appears as if it is undefined: > myArray = [‘a’, ‘b’, ‘c’, ‘d’] [“a”, “b”, “c”, “d”] > delete myArray[0] true > myArray[0] undefined Note that it is not in fact set to the value undefined, … Read more