2021-07-07

    Copy & Run Code Examples Copy & Run Code Examples Copy & Run Code Examples

    Follow @hackingcpp on twitter so you don't miss any updates.

    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.

    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.

    standard library algorithm 'merge' visual example
    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) { cout << x << ' '; }  // 0 1 2 3 4 5 6 7 8