0Pricing
C++ Academy · Lesson

Non-Modifying Algorithms find count all_of

Search and test container contents without changing them.

Read-Only Operations

Non-modifying algorithms inspect a range without changing it. They live in <algorithm>.

std::find

Locate the first element equal to a value. Returns an iterator — end if not found.

#include <algorithm>
std::vector<int> v = {3, 1, 4, 1, 5};
auto it = std::find(v.begin(), v.end(), 4);
if (it != v.end()) std::cout << "found at " << (it - v.begin());

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