【发布时间】:2012-12-10 00:15:26
【问题描述】:
我想为需要在boost::unordered_map 中作为值类型的特定类型实现移动构造函数(无复制构造函数)。我们称这种类型为Composite。
Composite 具有以下签名:
struct Base
{
Base(..stuff, no default ctor) : initialization list {}
Base(Base&& other) : initialization list {}
}
struct Composite
{
Base member;
Composite(..stuff, no default ctor) : member(...) {}
Composite(Composite&& other) : member(other.member) {} // <---- I want to make sure this invokes the move ctor of Base
}
我想写这个,所以boost::unordered_map< Key , Composite > 不需要复制构造函数,只使用移动构造函数。如果可能,我不想在Composite的移动构造函数的初始化列表中使用Base的复制构造函数。
这可能吗?
【问题讨论】:
标签: c++ c++11 initialization unordered-map move-semantics