Copy & Run Code Examples Copy & Run Code Examples Copy & Run Code Examples
Follow @hackingcpp on twitter so you don't miss any updates.
Copy To Clipboard
Most code examples can now be copied to the system clipboard by clicking the clipboard button in the top right corner of a code box. This will also add all necessary boilerplate to the example that is needed to make it runnable.
Run In Compiler Explorer
Many code examples (including almost all standard algorithm examples) can also be opened and run in compiler explorer by pressing the play button in the top right corner of a code box.
Try it!
#include <vector>
#include <iostream>
#include <algorithm>
int main () {
std::vector<int> in1 {0,2,4,6,7};
std::vector<int> in2 {1,3,5,8};
// make sure output can fit all elements
std::vector<int> out;
out.resize(in1.size() + in2.size());
merge(begin(in1), end(in1), begin(in2), end(in2), begin(out));
for (int x : out) { std::cout << x << ' '; } // 0 1 2 3 4 5 6 7 8
std::cout << '\n';
}