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
- Non-Modifying Algorithms find count all_of
- Modifying transform copy_if replace
- Sorting and Partitioning sort stable_partition
- Numeric Algorithms accumulate reduce transform_reduce