<分区>
所以我有一种情况需要存储抽象类型的 vector ,据我所知这需要使用 unique_ptrs 或类似的 vector 。
因此,为了 move 包含 unique_ptr vector 的类的实例,我需要定义一个我已经完成的 move 构造函数。
然而,如下例所示,这似乎与编译器 (msvc) 不一致,编译器 (msvc) 给出了以下错误。
Error 1 error C2280: 'std::unique_ptr>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function
class SomeThing{
};
class Foo{
public:
Foo(){
}
Foo(const Foo&& other) :
m_bar(std::move(other.m_bar))
{};
std::vector<std::unique_ptr<SomeThing>> m_bar;
};
int main(int argc, char* argv[])
{
Foo f;
return 0;
}