0

One can quickly make a type noncopyable by inheriting boost::noncopyable_::noncopyable. Is there anything similar for preventing a type from being moveable?

4

1 回答 1

1

如果声明了复制构造函数但没有声明移动构造函数,则不会生成移动构造函数。分配也一样。所以:

struct not_movable {
    not_movable(const not_movable&) = default;
    not_movable& operator=(const not_movable&) = default;
};
于 2013-06-01T01:56:56.430 回答