首先,nullptr是C++11新标准下引入的一种特殊类型的字面值, 它可以被转换为任意其他的指针类型。其次:nullptr_t的定义看下:typedef decltype(nullptr) nullptr_t;
/*This type can only take one value: nullptr, which when converted to a pointer type takes the proper null pointer value.
Even though nullptr_t it is not a keyword, it identifies a distinct fundamental type: the type of nullptr. As such, it participates in overload resolution as a different type.*/
再者,u=nullptr;是一种特殊的拷贝,利用的是C++11新引入的移动构造函数和移动赋值运算符性质。换言之,这不是拷贝,这是移动。而且移动构造函数/移动赋值函数的第一个参数是一个右值引用。再来看下右值引用的绑定问题,由于解引用操作符生成左值,取地址运算符生成右值,所以指针nullptr是一个右值,可以被绑定到unique_ptr的移动操作构造函数/移动赋值运算符上。