【发布时间】:2019-04-23 05:59:35
【问题描述】:
我有boost::array<int,8> array1 和我有std::vector<int> temp(8); 我如何从boost::array 执行std::move() 到std::vector,我想避免memcpy()。
【问题讨论】:
-
“
std::move()从boost::array到std::vector”是什么意思?您是否只想从boost::array创建一个std::vector? -
我不知道
boost::array,但如果它是std::array之类的东西,它就没有移动语义。如果你移动,它会移动O(N)中的元素,但不能像std::vector一样移动O(1)中的存储。 -
在此处的有效 cmets 和答案中,您仍应避免使用
memcpy。使用std::copy()。