Algorithms library

cppreference.com

Constrained algorithms

C++20 provides constrained versions of most algorithms in the namespace std::ranges.

v: std::vector<int> = (7, 1, 4, 0, -1);
std::ranges::sort(v); // constrained algorithm

Non-modifying sequence operations

Batch operations


for_each

ranges::for_each

for_each_n

ranges::for_each_n

Search operations


all_of

any_of

none_of


ranges::all_of

ranges::any_of

ranges::none_of


ranges::contains

ranges::contains_subrange


find

find_if

find_if_not


ranges::find

ranges::find_if

ranges::find_if_not


ranges::find_last

ranges::find_last_if

ranges::find_last_if_not


find_end


ranges::find_end


find_first_of


ranges::find_first_of


adjacent_find


ranges::adjacent_find


count

count_if


ranges::count

ranges::count_if


mismatch


ranges::mismatch


equal


ranges::equal


search


ranges::search


search_n


ranges::search_n


ranges::starts_with


ranges::ends_with

Fold operations


ranges::fold_left


ranges::fold_left_first


ranges::fold_right


ranges::fold_right_last


ranges::fold_left_with_iter


ranges::fold_left_first_with_iter

Modifying sequence operations

Copy operations


copy

copy_if


ranges::copy

ranges::copy_if


copy_n


ranges::copy_n


copy_backward


ranges::copy_backward


move


ranges::move


move_backward


ranges::move_backward

Swap operations


swap_ranges


ranges::swap_ranges


iter_swap

Transform operations


transform


ranges::transform


replace

replace_if


ranges::replace

ranges::replace_if


replace_copy

replace_copy_if


ranges::replace_copy

ranges::replace_copy_if

Generation operations


fill


ranges::fill


fill_n


ranges::fill_n


generate


ranges::generate


generate_n


ranges::generate_n

Removing operations


remove

remove_if


ranges::remove

ranges::remove_if


remove_copy

remove_copy_if


Back to top

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