std::remove_copy, std::remove_copy_if

cppreference.com

Example

main: () = {
    // Erase the hash characters '#' on the fly.
    str: std::string = ("#Return #Value #Optimization");
    std::println("before: \"{}\"", str);

    std::cout << "after:  \"";
    std::remove_copy(str.begin(), str.end(),
                     std::ostream_iterator<char>(std::cout), '#');
    std::cout << "\"\n";

    // Erase {1, 3} value on the fly.
    nums: std::vector = (
        :std::complex<double>=(2, 2),
        :std::complex<double>=(1, 3),
        :std::complex<double>=(4, 8),
        :std::complex<double>=(1, 3));
    std::remove_copy(nums.begin(), nums.end(),
                     std::ostream_iterator<std::complex<double>>(std::cout),
                     std::complex<double>(1, 3));
}

Output

before: "#Return #Value #Optimization"
after:  "Return Value Optimization"
(2,2)(4,8)

Back to top

cpp2reference.com licensed under CC-BY-SA and GFDL.