Concatenating two std::vectors

后端 未结 25 2332
予麋鹿
予麋鹿 2020-11-22 12:00

How do I concatenate two std::vectors?

25条回答
  •  心在旅途
    2020-11-22 12:35

    With C++11, I'd prefer following to append vector b to a:

    std::move(b.begin(), b.end(), std::back_inserter(a));
    

    when a and b are not overlapped, and b is not going to be used anymore.


    This is std::move from , not the usual std::move from .

提交回复
热议问题