The standard (draft) says:
// 20.8.1.2.1, constructors ... template <class U, class E> unique_ptr(unique_ptr<U, E>&& u) noexcept; template <class U> unique_ptr(auto_ptr<U>&& u) noexcept;
These are constructors from any unique_ptr. The standard further restricts their use to the following reservations:
24 Notes: This constructor should not be involved in overload resolution if U* implicitly converted to T* and D is the same type as default_delete<T>
The effect of this remark is that unique_ptr<T> is constructive of unique_ptr<U> exactly U* can be converted to T* (and all delay requirements are met). In particular, when T is a single-valued publicly accessible base class U
Since the constructor is not explicit , it serves as an implicit converter from unique_ptr<U> to unique_ptr<T> .
source share