Inserting a vector of unique_ptr into another vector

后端 未结 2 1587
名媛妹妹
名媛妹妹 2020-12-17 15:45

I have a vector of unique_ptr\'s and I want to append them to another vector of unique_ptrs. I would normally do a simple insert:

std::vector

        
2条回答
  •  离开以前
    2020-12-17 16:41

    You can't copy them; you'll have to move them.

    std::move(baz.begin(), baz.end(), std::back_inserter(bar));
    

提交回复
热议问题