C++ 如何将一种类型的唯一_ptr复制到另一种类型

C++ 如何将一种类型的唯一_ptr复制到另一种类型,c++,c++11,unique-ptr,C++,C++11,Unique Ptr,参考以下代码 #include <iostream> #include <memory> using std::cout; using std::endl; using std::make_unique; struct Base {}; struct Derived : public Base {}; int main() { auto base_uptr = std::unique_ptr<Base>{make_unique<Derive

参考以下代码

#include <iostream>
#include <memory>
using std::cout;
using std::endl;
using std::make_unique;

struct Base {};
struct Derived : public Base {};

int main() {

    auto base_uptr = std::unique_ptr<Base>{make_unique<Derived>()};
    return 0;
}
它们似乎都不接受其他类型的指针。我错过了什么?调用哪个构造函数


谢谢

第6个,模板构造函数

template< class U, class E >
unique_ptr( unique_ptr<U, E>&& u );
模板
唯一的(唯一的);
在其他一些条件中,它要求“
unique\u ptr::pointer
可以隐式转换为
pointer
”。换句话说,
U*
需要隐式转换为
unique\U ptr
存储的指针类型。在您的例子中,它是,因为
派生的*
隐式地可转换为
Base*

template< class U, class E >
unique_ptr( unique_ptr<U, E>&& u );