Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 579 Bytes

copy_n.md

File metadata and controls

19 lines (15 loc) · 579 Bytes

copy_n

Description : Copies n elements starting in the ranged passed, to another range beginning at passed argument.

Example:

    std::vector<int> origin {1, 2, 3};
    std::vector<int> destination;

    // Will copy 2 values starting at origin.begin, to destination
    std::copy_n(origin.begin(), 2, std::back_inserter(destination));
    
    // destination is now {1, 2}
    for (auto value : destination) { 
        std::cout << value << " "; 
    }

See Sample code Run Code