How do I concatenate two std::vector
s?
There is an algorithm std::merge from C++17, which is very easy to use when the input vectors are sorted,
Below is the example:
#include
#include
#include
int main()
{
//DATA
std::vector v1{2,4,6,8};
std::vector v2{12,14,16,18};
//MERGE
std::vector dst;
std::merge(v1.begin(), v1.end(), v2.begin(), v2.end(), std::back_inserter(dst));
//PRINT
for(auto item:dst)
std::cout<