0Pricing
C++ Academy · Lesson

Modifying transform copy_if replace

Transform, filter and replace elements with standard algorithms.

Modifying Algorithms

These algorithms write to an output range — either in place or to a destination iterator.

std::copy

Copy a range into another. The output range must be large enough or you must provide an inserter.

#include <algorithm>
#include <iterator>
std::vector<int> src = {1, 2, 3};
std::vector<int> dst;
std::copy(src.begin(), src.end(), std::back_inserter(dst));

All lessons in this course

  1. Non-Modifying Algorithms find count all_of
  2. Modifying transform copy_if replace
  3. Sorting and Partitioning sort stable_partition
  4. Numeric Algorithms accumulate reduce transform_reduce
← Back to C++ Academy