2017-06-15 52 views
-1

这是对我早期问题Explicit move constructor needed in container?的修改。在没有编译器定义的移动构造函数的容器中显式移动构造函数?

我有一个模板容器类:

template<class Stuff> 
class Bag{ 
    public: 
     ~Bag() {//Do some stuff here so that the compiler doesn't implement move semantics} 
    private: 
     std::vector<Stuff> mData; 
}; 

我想做

void InPlace(Bag<Array>& Left){ 
    Bag<Array> temp; 
    Transform(Left, temp); //fills temp with desirable output 
    Left = std::move(temp); 
} 

假设数组有用户定义的移动语义,但袋没有。在这种情况下mData是否会被移动或复制?

+2

您打算询问关于该网格中每一行的问题吗? –

+0

如果'Bag'不能移动,为什么会发生移动? – NathanOliver

+0

[问题2](https://stackoverflow.com/q/44573222/7359094)你问了2个小时前。 –

回答

1

如果Bag不支持移动语义,则不存在适用的移动操作。复制任务/施工将相应地进行。

+0

顺便说一句。温度是一个左值,所以它不会导致这里的移动。 – Samxion