reset ist implemented as
pointer old = this->ptr; this->ptr= newPointer; delete[] old;
Template overload is removed for arrays to prevent the following case
class foo{}; class bar : public foo {}; foo* managedPointer = new foo[3]; bar* newPointer = new bar[5]; foo* old = managedPointer; managedPointer = newPointer; delete[] old;
What behavior is undefined. Section 5.3.5, paragraph 3:
[...] In the second alternative (delete array), if the dynamic type of the object to be deleted is different from its static type, the behavior is undefined.
Since remote functions are still involved in overload resolution and reset(U) provides a better match for nullptr than reset(pointer) , there is an additional overload to enable reset(nullptr) , which otherwise would give a compiler error and thus , would lead to an inconsistent interface between the array and the version of the pointer.
source share