Generic merge algorithms: Merge the two sorted halves of vector3 in place to obtain a sorted vector3 : inplace_merge « STL Algorithms Merge « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  vector<int> vector1(5);
  vector<int> vector2(5);
  vector<int> vector3(10);

  for (int i = 0; i < 5; ++i)
    vector1[i] = 2 * i;

  for (int i = 0; i < 5; ++i)
    vector2[i] = 1 + 2 * i;


  merge(vector1.begin(), vector1.end(), vector2.begin(), vector2.end(), vector3.begin());

  
  inplace_merge(vector3.begin(), vector3.begin() + 5,vector3.end());

  for (int i = 0; i < 10; ++i)
    cout << vector3[i];

  return 0;
}
0123456789








28.2.inplace_merge
28.2.1.std::inplace_merge
28.2.2.inplace_merge a list
28.2.3.Generic merge algorithms: Merge the two sorted halves of vector3 in place to obtain a sorted vector3
28.2.4.inplace_merge, reverse_copy, and unique_copy.