A possible reason is that the unique_ptr constructor, which takes a unique_ptr::pointer argument, is explicit . This means that in the absence of the unique_ptr(nullptr_t) constructor, the following code will not compile.
std::unique_ptr<int> intp = nullptr;
Since a unique_ptr intended for a lightweight smart pointer that closely mimics the semantics of a raw pointer, it is advisable that the code above be compiled.
In the first example, the nullptr_t constructor nullptr_t not called because the argument type is Foo* , although its value is nullptr .
source share