C++

'std::find_if_not' Is Not a Member of 'std' Fix

std::find_if_not lives in one header, <algorithm> - not in <vector>, where the containers it searches live, and not in any header a searching program already has by habit. On this library version a handful of headers rescue it by accident: in the sweep probed here, covering all 106 standard headers in the library's header set, <execution>, <functional>, <regex>, and <valarray> pull the name in on the side, and the textbook combination of <iostream> and <vector> does not. This name also has a second cause its older sibling does not: it is a C++11 function, so a file compiled as C++98 fails with the same not-a-member error even with the include present. This guide pins down the plain failing shape, the four transitive rescues, the one include that fixes the common case, and the standard flag that fixes the other one.

Written December 2, 2026 · Tested with GCC 13.3.0 · 24 min read

By the end of this guide
  • The error: the include is missing, in a lean file
  • The textbook version fails too - plainly, with no suggestion to follow
  • Neighboring headers: 101 fail plainly, none fail with a suggestion, and four rescue it
  • The fix

Written December 2, 2026

Tested with GCC 13.3.0

What this guide is

std::find_if_not is a function template defined in the header <algorithm>. It returns an iterator to the first element in a range for which the given unary predicate returns false, or the range's end iterator if there is no such element. The range's iterators need only meet the input-iterator requirements - the weakest iterator category any algorithm in this family accepts - the predicate must meet the predicate requirements, and the search applies the predicate at most once per element. The classic overload has existed since C++11 and returns the found iterator itself: there is no count, no flag, and no separate end marker to read.

Because the function lives in one specific header, 'find_if_not' is not a member of 'std' has two causes, and telling them apart is the first step:

  • The #include <algorithm> line is missing, and no other header in the file pulls the name in transitively. For this error, in the contexts probed here, GCC prints no suggestion tail, no note lines, and no help lines at all - every failing file gets the bare error line, as the sweep below shows.
  • The include is present but the file is compiled as C++98. std::find_if_not is a C++11 name, so the older standard does not declare it, and the same not-a-member error appears - this time carrying a suggestion tail naming find_if, as the versions section below shows. Its sibling std::find_if has no such second cause: that name predates C++11.

A searching program's file most often already holds <vector> for the container and <iostream> for printing, and in the sweep probed here both fail plainly - so the file a reader actually has gets the bare version of the error, with nothing in the diagnostic pointing anywhere. The sweep covers every one of the 106 standard headers in this library's header set, compiled as the only header in the program, and the outcome splits two ways - the plain failure or a rescue - and the rescue set has exactly five entries: <algorithm> itself, <execution>, <functional>, <regex>, and <valarray>.

The error: the include is missing, in a lean file

This program searches a five-element array for the first element that is not even, using a free-function predicate, but includes only <limits>:

C++
#include <limits>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    int a[5] = {2, 4, 5, 6, 8};
    int* it = std::find_if_not(a, a + 5, isEven);
    return it == a + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 a_limits.cpp -o a_limits_prog
a_limits.cpp: In function 'int main()':
a_limits.cpp:5:20: error: 'find_if_not' is not a member of 'std'
    5 |     int* it = std::find_if_not(a, a + 5, isEven);
      |                    ^~~~~~~~~~~

That is the whole output: one plain error line, and nothing after it. No suggestion tail rides on the error line itself, there are no note lines, and there are no help lines. The same program with no include at all fails the same way, just as bare, at the same call.

The textbook version fails too - plainly, with no suggestion to follow

The version most often written first - search a vector with a lambda predicate and print the result - gets the same error, without <algorithm>, and for this name the error line carries no tail:

C++
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {2, 4, 6, 8, 10, 11, 12, 14, 16, 18};
    auto it = std::find_if_not(v.begin(), v.end(), [](int x) { return x % 2 == 0; });
    std::cout << *it << " at " << (it - v.begin()) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 t_textbook.cpp -o t_textbook_prog
t_textbook.cpp: In function 'int main()':
t_textbook.cpp:5:20: error: 'find_if_not' is not a member of 'std'
    5 |     auto it = std::find_if_not(v.begin(), v.end(), [](int x) { return x % 2 == 0; });
      |                    ^~~~~~~~~~~

Nothing follows the caret line: no suggested name, no marker line under the caret, no notes. That plainness is this name's own shape, and it differs from its sibling's - a std::find_if call in a file holding <iostream> gets a did you mean 'find'? tail, but no header in the sweep below gives std::find_if_not any tail at all. The one suggestion this name ever earns appears in a different situation entirely - the C++98 file in the versions section, where the include is present and the standard is the problem. The fix here is unchanged by any tail: the negated predicate search takes <algorithm>, and neither <iostream> nor <vector> rescues it - in the sweep probed here, the only headers that rescue std::find_if_not besides <algorithm> itself are <execution>, <functional>, <regex>, and <valarray>, and those rescues are properties of this library version, not rules of the language. A program that uses std::find_if_not includes <algorithm>, whether or not it happens to compile without it.

Neighboring headers: 101 fail plainly, none fail with a suggestion, and four rescue it

In a sweep where each of the 106 standard headers in this library's header set was compiled as the only header in a program that searches a five-element array with a free-function predicate, the outcome splits by compile result and diagnostic shape two ways. Every diagnostic component was classified separately - the error line, any suggestion tail on it, any note lines, and any help lines. These 101 headers all fail with the plain is not a member of 'std' error line, no suggestion tail on that line, no note lines at all, and no help lines:

  • <any>
  • <array>
  • <atomic>
  • <barrier>
  • <bit>
  • <bitset>
  • <cassert>
  • <ccomplex>
  • <cctype>
  • <cerrno>
  • <cfenv>
  • <cfloat>
  • <charconv>
  • <chrono>
  • <cinttypes>
  • <ciso646>
  • <climits>
  • <clocale>
  • <cmath>
  • <codecvt>
  • <compare>
  • <complex>
  • <concepts>
  • <condition_variable>
  • <coroutine>
  • <csetjmp>
  • <csignal>
  • <cstdalign>
  • <cstdarg>
  • <cstdbool>
  • <cstddef>
  • <cstdint>
  • <cstdio>
  • <cstdlib>
  • <cstring>
  • <ctgmath>
  • <ctime>
  • <cuchar>
  • <cwchar>
  • <cwctype>
  • <deque>
  • <exception>
  • <expected>
  • <filesystem>
  • <format>
  • <forward_list>
  • <fstream>
  • <future>
  • <initializer_list>
  • <iomanip>
  • <ios>
  • <iosfwd>
  • <iostream>
  • <istream>
  • <iterator>
  • <latch>
  • <limits>
  • <list>
  • <locale>
  • <map>
  • <memory>
  • <memory_resource>
  • <mutex>
  • <new>
  • <numbers>
  • <numeric>
  • <optional>
  • <ostream>
  • <queue>
  • <random>
  • <ranges>
  • <ratio>
  • <scoped_allocator>
  • <semaphore>
  • <set>
  • <shared_mutex>
  • <source_location>
  • <span>
  • <spanstream>
  • <sstream>
  • <stack>
  • <stacktrace>
  • <stdexcept>
  • <stdfloat>
  • <stop_token>
  • <streambuf>
  • <string>
  • <string_view>
  • <syncstream>
  • <system_error>
  • <thread>
  • <tuple>
  • <type_traits>
  • <typeindex>
  • <typeinfo>
  • <unordered_map>
  • <unordered_set>
  • <utility>
  • <variant>
  • <vector>
  • <version>

A file with no include at all fails plainly the same way. No failing sole header prints a suggestion tail, a note line, or a help line anywhere in this sweep - the suggestion class that other names in this family have is empty for std::find_if_not.

A sole <vector> file shows the plain shape in full - and <vector> is the header this call is most often expected in, since the container being searched comes from it. It is not there:

C++
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {2, 4, 5, 6};
    std::vector<int>::iterator it = std::find_if_not(v.begin(), v.end(), isEven);
    return it == v.begin() + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 v_vector.cpp -o v_vector_prog
v_vector.cpp: In function 'int main()':
v_vector.cpp:5:42: error: 'find_if_not' is not a member of 'std'
    5 |     std::vector<int>::iterator it = std::find_if_not(v.begin(), v.end(), isEven);
      |                                          ^~~~~~~~~~~

And these headers rescue the program - it compiles and runs with no <algorithm> anywhere in the file:

  • <algorithm>
  • <execution>
  • <functional>
  • <regex>
  • <valarray>

Two contrasts with the neighboring sweeps are worth holding on to. First, the plain class is this name's only failing shape: there is no suggestion class and no link-failure shape in this sweep, so every failing sole header fails at compile time with the same bare error line - the diagnostic gives the reader nothing beyond the name and the fact that std does not have it. Second, the rescue set has no visible container or iterator shape: the rescues are two execution and functional headers, the regular-expression header, and <valarray> - headers that pull the algorithm header's internals in on the side, which is consistent with a name whose home is the general algorithms header, not the container header its ranges usually come from. <algorithm> - the home header - is on the rescue list by definition, not by transitivity, and the other four rescues are this library version's behavior, not a guarantee.

The fix

Add the header:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {2, 4, 6, 8, 10, 11, 12, 14, 16, 18};
    auto it = std::find_if_not(v.begin(), v.end(), [](int x) { return x % 2 == 0; });
    std::cout << *it << " at " << (it - v.begin()) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 h_fixed.cpp -o h_fixed_prog
$ ./h_fixed_prog
11 at 5

One include, <algorithm>, declares the function - and the search reports 11 at 5: the value 11, the first element of the population that is not even, at index 5, behind five elements the predicate accepts. The returned iterator is the whole result: dereferencing it gives the element, and subtracting the range's beginning gives its position.

The return value is the result: found, not found, and first-element

The three outcomes of the call are three positions of the one returned iterator. A match partway through the range, a range with no match at all, and a match on the very first element:

C++
#include <algorithm>
#include <iostream>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    int a[4] = {2, 4, 5, 6};
    int* it = std::find_if_not(a, a + 4, isEven);
    std::cout << *it << " at " << (it - a) << "\n";
    int b[3] = {2, 4, 6};
    int* it2 = std::find_if_not(b, b + 3, isEven);
    std::cout << (it2 == b + 3 ? "end" : "found") << " " << (it2 - b) << "\n";
    int c[3] = {1, 2, 3};
    int* it3 = std::find_if_not(c, c + 3, isEven);
    std::cout << *it3 << " at " << (it3 - c) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 r_return.cpp -o r_return_prog
$ ./r_return_prog
5 at 2
end 3
1 at 0

Read in order: over 2, 4, 5, 6 the search reports 5 at 2 - the first element the predicate rejects is the third one, because the search stops at the first rejection and does not continue to the 6 behind it. Over 2, 4, 6, where everything is even, the return is the end iterator itself, reported as end 3 - one past the last element, the position the caller compares against to detect the miss; dereferencing that iterator is not a result, it is outside the range. And over 1, 2, 3 the first element already fails the predicate, reported as 1 at 0. Code that uses this function branches on that one comparison - returned iterator against the range's end - and both branches are ordinary outcomes, not errors.

The edge ranges: empty and no match

Neither short range is an error. A search over an empty range returns that range's end at once, and a one-element range whose element satisfies the predicate - so the negated search finds nothing in it - returns its end the same way:

C++
#include <algorithm>
#include <iostream>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    int a[1] = {8};
    int* it = std::find_if_not(a, a, isEven);
    std::cout << (it == a ? "empty end" : "found") << "\n";
    int* it2 = std::find_if_not(a, a + 1, isEven);
    std::cout << (it2 == a + 1 ? "no match end" : "found") << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 k_empty.cpp -o k_empty_prog
$ ./k_empty_prog
empty end
no match end

Input iterators: the search runs on a stream

The iterator requirement is the weakest in this family: input iterators suffice, so the range does not need to be a container at all. This program searches a stream of integers read one at a time - a range that cannot be rewound and cannot be indexed - and finds the first value that is not even:

C++
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::istringstream in("2 4 5 6");
    std::istream_iterator<int> first(in), last;
    std::istream_iterator<int> it = std::find_if_not(first, last, isEven);
    std::cout << *it << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 i_stream.cpp -o i_stream_prog
$ ./i_stream_prog
5

That is a range shape the forward-iterator algorithms in this family cannot run over at all: a stream iterator can be read once, in order, and std::find_if_not is specified to need nothing more - at most one predicate application per element, in order, stopping at the first element the predicate rejects.

Versions: this name has a second cause - it is a C++11 function

Unlike its sibling, this call does need a modern standard. The fixed programs in this guide are compiled as C++17, but the classic call's floor is C++11: with <algorithm> included, the same call compiled as C++98 fails - with the not-a-member error, and with the only suggestion tail this name earns anywhere in this guide:

C++
#include <algorithm>
#include <iostream>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    int a[5] = {2, 4, 5, 6, 8};
    int* it = std::find_if_not(a, a + 5, isEven);
    std::cout << *it << " at " << (it - a) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++98 c_version98.cpp -o c_version98_prog
c_version98.cpp: In function 'int main()':
c_version98.cpp:6:20: error: 'find_if_not' is not a member of 'std'; did you mean 'find_if'?
    6 |     int* it = std::find_if_not(a, a + 5, isEven);
      |                    ^~~~~~~~~~~
      |                    find_if

The tail names find_if because under C++98 that is the closest name std does have - and it is a genuinely usable direction, since the documented pre-C++11 equivalent of std::find_if_not is std::find_if with the predicate negated. But the direct fix is the flag, not the rewrite: the identical file compiled as C++11 compiles and runs:

Terminal
$ g++ -std=c++11 c_version98.cpp -o c_version98_prog
$ ./c_version98_prog
5 at 2

So this name's error has two independent causes with two different fixes, and the diagnostic separates them: a missing include fails plainly under any standard, while an include-present C++98 file fails with the find_if tail. When the include is missing, no standard flag rescues the call; when the standard is C++98, no include rescues it either. The newer pieces are separate overloads and uses layered on top of the classic call. The execution-policy overload is C++17, and it splits the include question in two: the overloads are declared by <algorithm>, but the policy objects live in <execution>, so a policy call with only <algorithm> included fails on the policy's name, not the algorithm's:

C++
#include <algorithm>
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {2, 4, 5, 6};
    std::vector<int>::iterator it = std::find_if_not(std::execution::seq, v.begin(), v.end(), isEven);
    return it == v.begin() + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 p_policy_algoonly.cpp -o p_policy_algoonly_prog
p_policy_algoonly.cpp: In function 'int main()':
p_policy_algoonly.cpp:6:59: error: 'std::execution' has not been declared
    6 |     std::vector<int>::iterator it = std::find_if_not(std::execution::seq, v.begin(), v.end(), isEven);
      |                                                           ^~~~~~~~~

That wording - has not been declared, naming std::execution - is a different defect with a different missing header: add <execution> alongside <algorithm>, and the same call compiles and runs:

C++
#include <algorithm>
#include <execution>
#include <iostream>
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {2, 4, 5, 6};
    std::vector<int>::iterator it = std::find_if_not(std::execution::seq, v.begin(), v.end(), isEven);
    std::cout << *it << " at " << (it - v.begin()) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 p_policy_fixed.cpp -o p_policy_fixed_prog
$ ./p_policy_fixed_prog
5 at 2

And since C++20 the classic call is also usable in constant expressions - this program's search runs at compile time, and the assertion on its result is part of the build:

C++
#include <algorithm>
#include <array>
constexpr bool isEven(int x) { return x % 2 == 0; }
constexpr int firstNotEven() {
    std::array<int, 5> a = {2, 4, 5, 6, 8};
    auto it = std::find_if_not(a.begin(), a.end(), isEven);
    return it == a.end() ? -1 : *it;
}
static_assert(firstNotEven() == 5);
int main() { return 0; }
Command
$ g++ -std=c++20 c_constexpr20.cpp -o c_constexpr20_prog
$ ./c_constexpr20_prog

The neighboring name: find_if is not in either

The name std::find_if_not negates does not live in the container's header either. std::find_if - the original search, which returns the first element for which the predicate returns true - lives in <algorithm> alongside std::find_if_not, and it fails in a file whose only include is <vector> with its own plain error and no suggestion tail. It is shown here only as a neighbor, not re-taught:

C++
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {1, 2, 3, 4, 5};
    std::vector<int>::iterator it = std::find_if(v.begin(), v.end(), isEven);
    return it == v.begin() + 1 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 b_findif_vector.cpp -o b_findif_vector_prog
b_findif_vector.cpp: In function 'int main()':
b_findif_vector.cpp:5:42: error: 'find_if' is not a member of 'std'
    5 |     std::vector<int>::iterator it = std::find_if(v.begin(), v.end(), isEven);
      |                                          ^~~~~~~

One difference between the neighbors matters for the versions question: std::find_if predates C++11, where std::find_if_not is a C++11 name - so the too-old-standard cause that does not exist for find_if does exist for its negation, and a C++98 file that includes <algorithm> and calls std::find_if_not gets the not-a-member error for the standard's reason, not the include's, as the versions section above shows.

The neighboring names, fixed

The two names together take the same one added header - <algorithm> covers both, and <vector> covers neither algorithm, only the container they search. The fixed neighbor program reports 2 at 1 for the first even element in 1, 2, 3, 4, 5 - the second element, behind one element the predicate rejects:

C++
#include <algorithm>
#include <iostream>
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {1, 2, 3, 4, 5};
    std::vector<int>::iterator it = std::find_if(v.begin(), v.end(), isEven);
    std::cout << *it << " at " << (it - v.begin()) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++17 b_findif_fixed.cpp -o b_findif_fixed_prog
$ ./b_findif_fixed_prog
2 at 1

The split is the whole lesson of this family: the algorithms take <algorithm> and the container takes <vector>, the two headers are both needed by a complete searching program, and a file that has only the container's header gets the not-a-member error for either algorithm name - plainly for both, in every include context probed here.

A different wording - and an argument-dependent rescue that depends on every argument

Including <algorithm> is not the only half of the name, and for this call the unqualified form splits on all of its arguments - the range's iterators and the predicate's type alike. Over plain arrays with a free-function predicate, the unqualified call fails:

C++
#include <algorithm>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    int a[5] = {2, 4, 5, 6, 8};
    int* it = find_if_not(a, a + 5, isEven);
    return it == a + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 g_unqualified.cpp -o g_unqualified_prog
g_unqualified.cpp: In function 'int main()':
g_unqualified.cpp:5:15: error: 'find_if_not' was not declared in this scope; did you mean 'std::find_if_not'?
    5 |     int* it = find_if_not(a, a + 5, isEven);
      |               ^~~~~~~~~~~
      |               std::find_if_not
In file included from /usr/include/c++/13/algorithm:73,
                 from g_unqualified.cpp:1:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:56:1: note: 'std::find_if_not' declared here
   56 | find_if_not(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
      | ^~~~~~~~~~~

That wording - was not declared in this scope, with did you mean 'std::find_if_not'? on the error line and a note pointing at a declaration - is a different defect with a different fix: the header is present, the qualifier is not. Qualify the name as std::find_if_not; adding includes does not bring the name out of namespace std. (The note happens to point at the execution-policy overload's declaration in a library-internal header - the classic overload is declared in the same home header's internals; the note's target is a detail of this library's layout, not a second home for the name.) Swapping the free-function predicate for a lambda over the same plain array changes nothing - a lambda's type has no associated namespace either, and the call fails with the same wording:

C++
#include <algorithm>
int main() {
    int a[5] = {2, 4, 5, 6, 8};
    int* it = find_if_not(a, a + 5, [](int x) { return x % 2 == 0; });
    return it == a + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 g_unqualified_lambda.cpp -o g_unqualified_lambda_prog
g_unqualified_lambda.cpp: In function 'int main()':
g_unqualified_lambda.cpp:4:15: error: 'find_if_not' was not declared in this scope; did you mean 'std::find_if_not'?
    4 |     int* it = find_if_not(a, a + 5, [](int x) { return x % 2 == 0; });
      |               ^~~~~~~~~~~
      |               std::find_if_not
In file included from /usr/include/c++/13/algorithm:73,
                 from g_unqualified_lambda.cpp:1:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:56:1: note: 'std::find_if_not' declared here
   56 | find_if_not(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
      | ^~~~~~~~~~~

Swap the array for a vector, and the same unqualified call compiles and runs:

C++
#include <algorithm>
#include <vector>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::vector<int> v = {2, 4, 5, 6, 8};
    std::vector<int>::iterator it = find_if_not(v.begin(), v.end(), isEven);
    return it == v.begin() + 2 ? 0 : 1;
}
Command
$ g++ -std=c++17 g_unqualified_vec.cpp -o g_unqualified_vec_prog
$ ./g_unqualified_vec_prog

That compile is argument-dependent lookup at work, not a rule to rely on: the vector's iterators are std types, so their associated namespace is std, and lookup finds std::find_if_not through them. But the container being a std type is not enough by itself - over a std::array, the same unqualified call with the same free-function predicate fails with the same wording, because in this library a std::array's iterators are plain pointers, and a pointer has no associated namespace:

C++
#include <algorithm>
#include <array>
bool isEven(int x) { return x % 2 == 0; }
int main() {
    std::array<int, 5> a = {2, 4, 5, 6, 8};
    std::array<int, 5>::iterator it = find_if_not(a.begin(), a.end(), isEven);
    return it == a.begin() + 2 ? 0 : 1;
}
Terminal
$ g++ -std=c++17 g_unqualified_stdarray.cpp -o g_unqualified_stdarray_prog
g_unqualified_stdarray.cpp: In function 'int main()':
g_unqualified_stdarray.cpp:6:39: error: 'find_if_not' was not declared in this scope; did you mean 'std::find_if_not'?
    6 |     std::array<int, 5>::iterator it = find_if_not(a.begin(), a.end(), isEven);
      |                                       ^~~~~~~~~~~
      |                                       std::find_if_not
In file included from /usr/include/c++/13/algorithm:73,
                 from g_unqualified_stdarray.cpp:1:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:56:1: note: 'std::find_if_not' declared here
   56 | find_if_not(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
      | ^~~~~~~~~~~

And the rescue can come from the last argument instead of the first two: keep the plain array, but make the predicate a std type - a std::function wrapping the same test - and the unqualified call compiles and runs, because the predicate argument now has std as an associated namespace:

C++
#include <algorithm>
#include <functional>
int main() {
    int a[5] = {2, 4, 5, 6, 8};
    std::function<bool(int)> isEven = [](int x) { return x % 2 == 0; };
    int* it = find_if_not(a, a + 5, isEven);
    return it == a + 2 ? 0 : 1;
}
Command
$ g++ -std=c++17 g_unqualified_stdfunc.cpp -o g_unqualified_stdfunc_prog
$ ./g_unqualified_stdfunc_prog

Every argument is a possible carrier and none is a guarantee: plain arrays and pointers carry nothing, a free function and a lambda carry nothing, a vector's iterators carry the name, a std::array's pointer iterators do not, and a std::function predicate carries it on its own. Write the qualifier either way.

The exact rule

  • std::find_if_not is declared by #include <algorithm>, and by no other header by rule. In the sweep probed here, every one of the other 101 headers in the library's header set - among them <vector>, <iostream>, <numeric>, <string>, and <version> - does not declare it, and neither does a file with no include at all.
  • 'find_if_not' is not a member of 'std' has two causes. The missing-include cause: the <algorithm> include is missing and nothing else in the file pulled the name in - in the sweep probed here every failing sole header fails with one plain error line, no suggestion tail, no note lines, and no help lines, and no probed sole header produces a suggestion class, a note class, or a declared-but-not-defined link-failure shape for this name. The version cause: the include is present but the file is compiled as C++98, because std::find_if_not is a C++11 name - that failure carries the tail ; did you mean 'find_if'?.
  • The C++98 suggestion tail is a direction, not the direct fix. std::find_if with the predicate negated is the documented pre-C++11 equivalent of this function, so the suggested name can be made to work - but raising the standard to C++11 or later keeps the call as written, and is the fix when the project's standard can move.
  • In the sweep probed here, four headers besides <algorithm> rescue std::find_if_not transitively - <execution>, <functional>, <regex>, and <valarray> - so a file whose only include is one of those compiles and runs the call without <algorithm>. That is this library version's behavior, not a guarantee - in the probed set, no header besides <algorithm> is required to pull std::find_if_not in.
  • The result rules are the documented ones, as the fixed programs here show: the fixed program prints 11 at 5 for the first element that is not even in the population 2, 4, 6, 8, 10, 11, 12, 14, 16, 18; over 2, 4, 5, 6 the search prints 5 at 2, the first element the predicate rejects; and when every element qualifies the return is the end iterator itself - over 2, 4, 6 the program prints end 3. The returned iterator is compared against the range's end to tell a match from a miss, and the end iterator itself is never a match.
  • The edge ranges are ordinary: searching an empty range, or a one-element range whose element satisfies the predicate, returns that range's end - the edge program here prints empty end and no match end - because the return contract has the end position for exactly those cases.
  • The classic std::find_if_not is a C++11 function: with <algorithm> included it compiles and runs as C++11, reporting 5 at 2, fails as C++98 with the not-a-member error, and is usable in constant expressions since C++20. The execution-policy overload is C++17 and needs two headers: <algorithm> for the overload and <execution> for the policy objects - with only <algorithm> included, naming std::execution::seq fails with 'std::execution' has not been declared.
  • The range's iterators must meet the input-iterator requirements and the predicate must meet the predicate requirements; the predicate is applied at most once per element. The stream program here shows the floor in action: over a stream of integers read one at a time, the search prints 5, the first value that is not even.
  • std::find_if is not declared by #include <vector>: in the program here, which includes only <vector>, it gets its own is not a member of 'std' error, plain, with no suggestion tail - and the fixed neighbor program, which includes both <algorithm> and <vector>, prints 2 at 1 for the original search call. std::find_if predates C++11, so for that name a standard before C++11 is not a second cause.
  • 'find_if_not' was not declared in this scope for an unqualified find_if_not use is a different defect: qualify the name as std::find_if_not - the include alone does not bring the name out of namespace std. For this name the unqualified call's fate depends on every argument: over plain arrays with a free-function predicate or a lambda it fails, as the first two unqualified programs above show; over a vector's iterators it is rescued through argument-dependent lookup, as the third shows, because those iterators are std types; over a std::array's iterators it fails again, because in this library those iterators are plain pointers; and a predicate argument of a std type rescues the plain-array call through the predicate argument, as the last program shows. Qualify the name either way.

The fixes, ranked

  • First, check the include list of the file that names std::find_if_not. If <algorithm> is not there, add it - that is the fix in the common case, and it holds whether the file failed in a lean context or in a textbook file, or happened to compile before through a transitive rescue.
  • Second, if <algorithm> is already there and the error persists, check the standard flag: this name needs C++11 or later, and a C++98 build fails with the same error plus a find_if suggestion tail. Raise the standard where the project allows it; where it cannot move, the documented equivalent is std::find_if with the predicate negated.
  • Third, do not reach for <vector> because the call searches a container. In the sweep probed here, <vector> fails for std::find_if_not with the plain error - the container and the algorithm live in different headers, std::vector in <vector> and std::find_if_not in <algorithm>, and a complete program needs both.
  • Fourth, do not be reassured by <iostream> being present - in the sweep here it fails too, just as plainly - and do not remove <algorithm> because a file compiles without it: in the probed set four headers rescue it, and those rescues are not guaranteed.
  • Fifth, if the error names std::execution instead - 'std::execution' has not been declared - the missing header is the other one: add <execution> alongside <algorithm>. That error appears only on the policy overload's path; the classic call never names it.
  • Sixth, match the standard to the piece you are using beyond the classic call: the policy overload needs C++17, and constant-expression use needs C++20.
  • Seventh, if the error says was not declared in this scope instead, fix the name's qualifier to std::find_if_not as well - and do not rely on argument-dependent lookup to rescue the unqualified call, because a plain array, a std::array, a free-function predicate, and a lambda each remove that rescue in one shape or another.
  • Eighth, if the failing name is the neighboring one, the fix is the same header: find_if takes an added <algorithm> too - one header for both algorithm names, and <vector> for the container alone.

Which fix for which cause

  • #include <algorithm> missing, std::find_if_not used in a file whose only include is one of the 101 headers listed as failing plainly in the sweep section above, or that includes nothing: the message is 'find_if_not' is not a member of 'std', with no suggestion tail, no note lines, and no help lines - add #include <algorithm>.
  • std::find_if_not used in a textbook file including <iostream> and <vector>: the message is the same plain error, with no tail - add #include <algorithm>.
  • std::find_if_not used with only <algorithm>, <execution>, <functional>, <regex>, or <valarray> included: no error on this library version - add #include <algorithm> anyway when it is not the include already present, because the other four rescues are not guaranteed.
  • std::find_if_not used with <algorithm> included but the file compiled as C++98: the message is 'find_if_not' is not a member of 'std'; did you mean 'find_if'? - compile as C++11 or later, or rewrite the call as std::find_if with the predicate negated where the standard cannot move.
  • std::find_if_not called with an execution policy, <algorithm> included but <execution> not: the message is 'std::execution' has not been declared - add #include <execution> alongside <algorithm>, and compile as C++17 or later.
  • find_if_not used without the std:: qualifier, <algorithm> included, over array arguments with a free-function predicate or a lambda, or over a std::array's iterators: the message is 'find_if_not' was not declared in this scope; did you mean 'std::find_if_not'? - qualify the name as std::find_if_not. Over a vector's iterators, or over plain arrays with a std::function predicate, the same unqualified call compiles through argument-dependent lookup - qualify it anyway, so the call does not depend on any argument's type.

Checklist

  • Check the include list of the file that names the call, not just the project. The include must be in that file, or in a header that file includes directly by design.
  • Check the standard flag second: this is one of the names where the flag is a real cause - C++11 is the floor for the classic call, C++17 for the policy overload, C++20 for constant-expression use.
  • Do not import the container's header into this error: find_if and find_if_not take <algorithm> and std::vector takes <vector>, so there are two headers in a complete searching program, one for the algorithms and one for the container.
  • Do not assume the textbook includes rescue this name, and do not delete a working <algorithm> line because a file compiles without it. In the sweep here <iostream> and <vector> do not rescue std::find_if_not at all, and the four headers that do rescue it do so only transitively.
  • Compare the returned iterator against the range's end before dereferencing it: the end return is the not-found answer, not an element. The fixed programs here print 11 at 5 for the found case and end 3 for the miss.
  • After the fix, confirm the program runs, not just that it compiles: the fixed programs here print 11 at 5 for the ten-element search, 5 at 2, end 3, and 1 at 0 for the return-value cases, 5 at 2 for the C++11 and policy calls, and 5 for the stream search, and 2 at 1 for the neighbor search call.
  • 'std::find_if' Is Not a Member of 'std' Fix - the same missing-include shape for the search this guide's function negates, in the same header: std::find_if returns the first element its predicate accepts where std::find_if_not returns the first it rejects, the two sweeps share the same five-entry rescue set, and the two calls differ in their failing shapes - find_if earns a find suggestion tail from 13 headers and has no version second cause, where find_if_not fails plainly from every header and is the one with the C++11 floor.
  • 'std::find' Is Not a Member of 'std' Fix - the same missing-include shape for the value-search sibling in the same header: std::find compares elements against a value where std::find_if_not applies a predicate and negates it - and it is a name from this family's suggestion tails, pointed at by the find_if diagnostic, so neither call is fixed by another's spelling; both take <algorithm>.

Sources

  • cppreference, std::find, std::find_if, std::find_if_not — for std::find_if_not being a function template defined in <algorithm>; for std::find_if_not being marked since C++11 and constexpr since C++20, while the classic std::find_if carries no since-version marker of its own; for the execution-policy overloads being since C++17; for the return being the first iterator for which the predicate returns false, or last if there is no such iterator; for the iterators needing to meet the input-iterator requirements and the predicate the predicate requirements, with the predicate expression needing to be convertible to bool and not modifying its argument; for the complexity being at most one predicate application per element; and for the note that, where C++11 is not available, an equivalent to std::find_if_not is std::find_if with the negated predicate.
  • cppreference, Standard library header <algorithm> — for <algorithm> being the header whose synopsis declares std::find, std::find_if, and std::find_if_not, the home-header fact both the fix and the neighbor sections of this guide rest on.

Keep Exploring