C++
'std::binary_search' Is Not a Member of 'std' Fix
std::binary_search lives in one header, <algorithm> - and on this library version almost no ordinary file rescues it by accident: in the sweep probed here only <functional> and <chrono> pull the name in on the side, and the textbook combination of <iostream> and <vector> does not. The error therefore surfaces in textbook files as well as lean ones, and in the sweep probed here it splits by compile result only two ways - the plain error, with no suggestion tail, no note lines, and no help lines in any probed failing context, or one of those two transitive rescues - with no link-failure shape behind any probed header. This guide pins down both outcomes, which probed headers cause each one, and the one include that fixes the error by specification.
Written December 1, 2026 · Tested with GCC 13.3.0 · 19 min read
- The error: the include is missing, in a lean file
- A neighboring header does not rescue it: only <utility>
- The textbook version fails too - plainly, with no suggestion
- Neighboring headers: which ones fail, which ones rescue it
Written December 1, 2026
Tested with GCC 13.3.0
What this guide is
std::binary_search is a function template defined in the header <algorithm>. It takes a range [first, last), which needs only to be partitioned with respect to value and is usually sorted, and a value, and returns true if an element equivalent to value exists in the range - an element that neither orders before nor orders after value - and false otherwise. The default overload orders by operator< (by std::less{} since C++20); a second overload takes a comparator comp and orders by comp instead. Both overloads are constexpr since C++20, and each makes at most log2(N)+O(1) comparisons for a range of N elements. It reports presence only: to get an iterator to the element itself, std::lower_bound is the tool, and std::equal_range brackets every element equivalent to the value.
Because the template lives in one specific header, 'binary_search' is not a member of 'std' has one common cause:
- 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 note naming<algorithm>, no suggestion on the error line, no note lines, and no help lines, so the fix has to come from knowing the name's home, not from reading a diagnostic tail. The neighboring names probed here -std::lower_bound,std::upper_bound, andstd::equal_range, all in the same header - are silent the same way in the same lean context, as the neighboring-names section shows.
What makes this error worth separating from its relatives is the shape of the sweep behind it. In the sweep probed here the outcome splits by compile result only two ways - the plain compile error, or a transitive rescue - and the rescue side is unusually small: only two probed headers besides <algorithm> itself rescue this name. The error is also plainer than its closest sibling's: std::upper_bound, probed in its own guide, picks up a did you mean 'lower_bound'? suggestion in eleven probed contexts and in the textbook file, while among the probed headers here std::binary_search picks up no suggestion anywhere, not even in the textbook file. The older siblings in this family - std::lower_bound, std::upper_bound, std::equal_range, std::sort, and std::find - have their own guides and are linked at the end, not re-taught here.
The error: the include is missing, in a lean file
This program searches a sorted array for the value 5 with std::binary_search and returns success if it is present, but includes only <limits>:
#include <limits>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::binary_search(a, a + 6, 5) ? 0 : 1;
}
$ g++ -std=c++20 a_limits.cpp -o a_limits_prog
a_limits.cpp: In function 'int main()':
a_limits.cpp:4:17: error: 'binary_search' is not a member of 'std'
4 | return std::binary_search(a, a + 6, 5) ? 0 : 1;
| ^~~~~~~~~~~~~
That is the whole output: one error, no suggestion on the error line, no note lines, no help lines. The same program with no include at all fails the same way:
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::binary_search(a, a + 6, 5) ? 0 : 1;
}
$ g++ -std=c++20 n_none.cpp -o n_none_prog
n_none.cpp: In function 'int main()':
n_none.cpp:3:17: error: 'binary_search' is not a member of 'std'
3 | return std::binary_search(a, a + 6, 5) ? 0 : 1;
| ^~~~~~~~~~~~~
A neighboring header does not rescue it: only <utility>
A reader coming from the std::swap error might reach for <utility> first. In the program probed here it changes nothing - the same plain error, at the same position:
#include <utility>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::binary_search(a, a + 6, 5) ? 0 : 1;
}
$ g++ -std=c++20 u_utility.cpp -o u_utility_prog
u_utility.cpp: In function 'int main()':
u_utility.cpp:4:17: error: 'binary_search' is not a member of 'std'
4 | return std::binary_search(a, a + 6, 5) ? 0 : 1;
| ^~~~~~~~~~~~~
That is expected once the homes are separated: <utility> declares std::swap, and std::binary_search is not one of its names. The two errors share a shape and a sentence pattern, but each name takes its own header, and the fix below is <algorithm>, not the swap fix.
The textbook version fails too - plainly, with no suggestion
The version most often written first - search a vector and print whether 5 is present, with std::cout - gets the same error, without <algorithm>:
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
std::cout << std::binary_search(v.begin(), v.end(), 5) << "\n";
return 0;
}
$ g++ -std=c++20 t_textbook.cpp -o t_textbook_prog
t_textbook.cpp: In function 'int main()':
t_textbook.cpp:5:23: error: 'binary_search' is not a member of 'std'
5 | std::cout << std::binary_search(v.begin(), v.end(), 5) << "\n";
| ^~~~~~~~~~~~~
What happened: on this library version, neither <vector> nor <iostream> pulls this name in transitively, so the call fails in a textbook file just as it does in a lean one. The error is also exactly as plain here as in the lean file: there is no did you mean tail on the error line, no note lines, and no help lines. That is a real contrast with the sibling error - in the same textbook context, std::upper_bound gets a did you mean 'lower_bound'? suggestion, because that neighboring name is visible there - while among the probed headers no context gives std::binary_search any suggestion at all. Do not wait for a suggestion to point the way: the fix for the name the program means is the include below. In the sweep probed here, the only headers that rescue std::binary_search are <functional> and <chrono>, besides <algorithm> itself, and that rescue is a property of this library version, not a rule of the language. A program that uses std::binary_search includes <algorithm>, whether or not it happens to compile without it.
Neighboring headers: which ones fail, which ones rescue it
In a sweep where each header below was compiled as the only header in a program that searches a sorted array for the value 5 and returns whether it is present, the outcome splits by compile result two ways. Every diagnostic component was classified separately - the error line, any suggestion tail on it, any note lines, and any help lines - and these headers fail with the plain is not a member of 'std' error, with no suggestion, no note, and no help:
<limits><cstring><cstdint><cstddef><initializer_list><version><climits><cctype><new><typeinfo><type_traits><compare><concepts><ratio><bit><optional><numeric><tuple><mutex><exception><utility><vector><string><iostream><memory><array><map><set><thread><stdexcept><iterator><system_error>
A file with no include at all fails the same way. And these headers rescue the program - it compiles and runs with no <algorithm> anywhere in the file:
<algorithm><functional><chrono>
Two contrasts with the neighboring sweeps are worth holding on to. First, the split here is two-way: in the sweep probed here, every failing sole header fails at compile time with the plain error - each one was also compiled to an object file on its own, and that step failed the same way - so the declared-but-not-defined link failure that std::swap produces behind five headers has no counterpart for this name in the probed set. Second, there is no suggestion class in this sweep at all: the eleven headers that add a did you mean 'lower_bound'? tail to the std::upper_bound error - <vector>, <string>, <iostream>, <memory>, <array>, <map>, <set>, <thread>, <stdexcept>, <iterator>, and <system_error> - fail plainly here, exactly like <limits> does. One header outside that sweep deserves a warning of its own: with only <semaphore> included, the same program fails with a suggestion tail — 'binary_search' is not a member of 'std'; did you mean 'binary_semaphore'? — because <semaphore> declares the similarly named std::binary_semaphore, and GCC offers the closest visible name. That suggestion names the wrong function entirely; the fix is still <algorithm>, not the suggested name. The rescue list, though, matches the short lists in this family: <algorithm> - the home header - is on this list by definition, not by transitivity, and every other rescue on that list is this library version's behavior, not a guarantee.
The fix
Add the header:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
std::cout << std::binary_search(v.begin(), v.end(), 5) << "\n";
return 0;
}
$ g++ -std=c++20 h_fixed.cpp -o h_fixed_prog
$ ./h_fixed_prog
1
One include, <algorithm>, declares the template. In the sorted vector 1, 2, 4, 5, 5, 6 the value 5 is present, so the program prints 1, for true.
The fixed programs: presence across the range
With <algorithm> added, std::binary_search answers for values below, inside, and above the range. In the same sorted vector, 0 is absent - printed as 0 - while 2, 5, and 6 are each present - printed as 1:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
for (int x : {0, 2, 5, 6}) std::cout << std::binary_search(v.begin(), v.end(), x) << " ";
std::cout << "\n";
return 0;
}
$ g++ -std=c++20 i_cases.cpp -o i_cases_prog
$ ./i_cases_prog
0 1 1 1
A value inside the range's span can still be absent: 3 sits between 2 and 4 in value but is not an element, so it reports 0, while 6, the last element, reports 1:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
std::cout << std::binary_search(v.begin(), v.end(), 3) << " " << std::binary_search(v.begin(), v.end(), 6) << "\n";
return 0;
}
$ g++ -std=c++20 k_values.cpp -o k_values_prog
$ ./k_values_prog
0 1
The comparator overload orders by the comparator instead of operator<. With std::greater<int> the range is written in descending order - 6, 5, 5, 4, 2, 1 - and 5 is present under that reversed ordering - printed as 1 - while the absent value 3 reports 0:
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {6, 5, 5, 4, 2, 1};
std::cout << std::binary_search(v.begin(), v.end(), 5, std::greater<int>()) << " " << std::binary_search(v.begin(), v.end(), 3, std::greater<int>()) << "\n";
return 0;
}
$ g++ -std=c++20 j_comp.cpp -o j_comp_prog
$ ./j_comp_prog
1 0
The neighboring names: same header, same silence
The binary-search names that std::binary_search is built alongside share its home header and its silence. std::lower_bound - the function template defined in <algorithm> that returns an iterator to the first element not less than the value - gets its own error, again with no header note:
#include <limits>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::lower_bound(a, a + 6, 5) - a == 3 ? 0 : 1;
}
$ g++ -std=c++20 b_lower.cpp -o b_lower_prog
b_lower.cpp: In function 'int main()':
b_lower.cpp:4:17: error: 'lower_bound' is not a member of 'std'
4 | return std::lower_bound(a, a + 6, 5) - a == 3 ? 0 : 1;
| ^~~~~~~~~~~
std::upper_bound - the function template defined in <algorithm> that returns an iterator to the first element greater than the value - fails the same way:
#include <limits>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::upper_bound(a, a + 6, 5) - a == 5 ? 0 : 1;
}
$ g++ -std=c++20 c_upper.cpp -o c_upper_prog
c_upper.cpp: In function 'int main()':
c_upper.cpp:4:17: error: 'upper_bound' is not a member of 'std'
4 | return std::upper_bound(a, a + 6, 5) - a == 5 ? 0 : 1;
| ^~~~~~~~~~~
std::equal_range - the function template defined in <algorithm> that returns the pair of bounds bracketing the elements equal to the value - fails the same way:
#include <limits>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
auto r = std::equal_range(a, a + 6, 5);
return r.second - r.first == 2 ? 0 : 1;
}
$ g++ -std=c++20 d_equal.cpp -o d_equal_prog
d_equal.cpp: In function 'int main()':
d_equal.cpp:4:19: error: 'equal_range' is not a member of 'std'
4 | auto r = std::equal_range(a, a + 6, 5);
| ^~~~~~~~~~~
One contrast is worth holding on to: in the lean programs here, binary_search, lower_bound, upper_bound, and equal_range all get no note and no suggestion. Do not read the absence of a diagnostic tail as a puzzle to solve - in this probed set the tail is simply absent for this header's names in this context, and the fix comes from the names' home, <algorithm>.
The neighboring names, fixed
And the neighboring names work under the same one added header: std::lower_bound for 5 sits at index 3, std::upper_bound for 5 sits at index 5, and the std::equal_range for 5 spans 2 elements:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
auto r = std::equal_range(v.begin(), v.end(), 5);
std::cout << std::lower_bound(v.begin(), v.end(), 5) - v.begin() << " " << std::upper_bound(v.begin(), v.end(), 5) - v.begin() << " " << (r.second - r.first) << "\n";
return 0;
}
$ g++ -std=c++20 k_neighbors_fixed.cpp -o k_neighbors_fixed_prog
$ ./k_neighbors_fixed_prog
3 5 2
Since C++20 the same <algorithm> header also declares std::ranges::binary_search, the ranges form of the same search. With <algorithm> included it takes the range itself instead of an iterator pair and reports 5 present - printed as 1 - and 3 absent - printed as 0; in the lean context - only <limits> included - it fails with its own wording, 'std::ranges' has not been declared, because the namespace itself is not declared there:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
std::cout << std::ranges::binary_search(v, 5) << " " << std::ranges::binary_search(v, 3) << "\n";
return 0;
}
$ g++ -std=c++20 r_ranges.cpp -o r_ranges_prog
$ ./r_ranges_prog
1 0
#include <limits>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return std::ranges::binary_search(a, 5) ? 0 : 1;
}
$ g++ -std=c++20 r2_ranges_lean.cpp -o r2_ranges_lean_prog
r2_ranges_lean.cpp: In function 'int main()':
r2_ranges_lean.cpp:4:17: error: 'std::ranges' has not been declared
4 | return std::ranges::binary_search(a, 5) ? 0 : 1;
| ^~~~~~
A different wording - and a case where the qualifier is not needed
Including <algorithm> is not the only half of the name - but for this function the unqualified form behaves two ways, and which one a program gets depends on its arguments. This program includes the header, drops the std:: qualifier, and passes raw pointers into a C array:
#include <algorithm>
int main() {
int a[] = {1, 2, 4, 5, 5, 6};
return binary_search(a, a + 6, 5) ? 0 : 1;
}
$ g++ -std=c++20 g2_unqualified_ptr.cpp -o g2_unqualified_ptr_prog
g2_unqualified_ptr.cpp: In function 'int main()':
g2_unqualified_ptr.cpp:4:12: error: 'binary_search' was not declared in this scope
4 | return binary_search(a, a + 6, 5) ? 0 : 1;
| ^~~~~~~~~~~~~
g2_unqualified_ptr.cpp:4:12: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61,
from g2_unqualified_ptr.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:2270:5: note: 'std::binary_search'
2270 | binary_search(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:2228:39: note: 'std::ranges::binary_search'
2228 | inline constexpr __binary_search_fn binary_search{};
| ^~~~~~~~~~~~~
That wording - was not declared in this scope - is a different defect with a different fix: the header is present, the qualifier is not, and raw pointers belong to no namespace, so no lookup finds the name. Here the suggestions do name the right names - the first points at std::binary_search itself, in the internal header the transcript names, and the second at std::ranges::binary_search. Qualify the name as std::binary_search; adding includes does not bring the name out of namespace std.
The same unqualified call with std::vector iterators as its arguments behaves differently - it compiles and runs, printing 1:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 4, 5, 5, 6};
std::cout << binary_search(v.begin(), v.end(), 5) << "\n";
return 0;
}
$ g++ -std=c++20 g_unqualified.cpp -o g_unqualified_prog
$ ./g_unqualified_prog
1
What happened: the iterators belong to namespace std, so argument-dependent lookup finds std::binary_search from the arguments themselves, even without the qualifier. That is a property of the argument types, not a style to rely on: the same call over raw pointers fails, as the transcript above shows. Write the qualifier either way.
The exact rule
std::binary_searchis declared by#include <algorithm>, and by no other header by rule. In the sweep probed here,<limits>,<cstring>,<cstdint>,<cstddef>,<initializer_list>,<version>,<climits>,<cctype>,<new>,<typeinfo>,<type_traits>,<compare>,<concepts>,<ratio>,<bit>,<optional>,<numeric>,<tuple>,<mutex>,<exception>,<utility>,<vector>,<string>,<iostream>,<memory>,<array>,<map>,<set>,<thread>,<stdexcept>,<iterator>, and<system_error>do not declare it, and neither does a file with no include at all.'binary_search' is not a member of 'std'means the<algorithm>include is missing and nothing else in the file pulled the name in - and, in the contexts probed here, GCC prints no note naming<algorithm>, no suggestion on the error line, no note lines, and no help lines under it, in the textbook context as well as the lean ones.- In the sweep probed here, the split by compile result is two-way: a sole header either fails with that plain compile error or rescues the program. Each failing sole header also failed when compiled to an object file on its own, so the probed set contains no declared-but-not-defined link-failure shape for this name.
- In the sweep probed here, only two headers besides
<algorithm>rescuestd::binary_searchtransitively -<functional>and<chrono>- 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, those headers are not required to pullstd::binary_searchin. std::lower_bound,std::upper_bound, andstd::equal_rangeare declared by the same#include <algorithm>: in the programs shown here, which include only<limits>beside the use, each gets its ownis not a member of 'std'error when that include is missing, with no header note.std::ranges::binary_searchis declared by the same#include <algorithm>since C++20: with the include it searches the range passed to it, and in the lean context probed here it gets the error'std::ranges' has not been declaredwhen that include is missing.'binary_search' was not declared in this scopefor an unqualifiedbinary_searchuse over raw pointers is a different defect: qualify the name asstd::binary_search- the include alone does not bring the name out of namespacestd. The same unqualified use overstd::vectoriterators compiles in the program probed here through argument-dependent lookup; qualify the name there too, so the call does not depend on its argument types.
The fixes, ranked
- First, check the include list of the file that names
std::binary_search. If<algorithm>is not there, add it - that is the fix in the common case, and it holds whether the file failed at compile time or happened to compile before through a transitive rescue. - Second, do not wait for a diagnostic tail to name the fix. In the contexts probed here this error carries no suggestion, no note, and no help - take the fix from the name the program means and its home header,
<algorithm>. - Third, do not reach for
<utility>because the error sentence looks like thestd::swaperror. In the program probed here,<utility>as the only include fails with the same plain error - the two names live in different headers, and each takes its own. - Fourth, do not be reassured by
<iostream>,<vector>, or<string>being present - in the sweep here none of them rescues this name at all - and do not remove<algorithm>because a file compiles without it: in the probed set only<functional>and<chrono>rescue it, and that rescue is not guaranteed. - Fifth, if the error says
was not declared in this scopeinstead, fix the name's qualifier tostd::binary_searchas well - and do not rely on an unqualified call that happens to compile overstditerators, because the same call over raw pointers fails. - Sixth, if the failing name is a neighboring one, check its header before fixing:
lower_bound,upper_bound, andequal_rangetake the same added<algorithm>, whileswaptakes<utility>.
Which fix for which cause
#include <algorithm>missing,std::binary_searchused in a file whose only include is<limits>,<cstring>,<cstdint>,<cstddef>,<initializer_list>,<version>,<climits>,<cctype>,<new>,<typeinfo>,<type_traits>,<compare>,<concepts>,<ratio>,<bit>,<optional>,<numeric>,<tuple>,<mutex>,<exception>,<utility>,<vector>,<string>,<iostream>,<memory>,<array>,<map>,<set>,<thread>,<stdexcept>,<iterator>, or<system_error>, or that includes nothing: the message is'binary_search' is not a member of 'std', with no suggestion, no header note, and no help - add#include <algorithm>.std::binary_searchused in a textbook file including<iostream>and<vector>: the message is the same plain error, with no suggestion - add#include <algorithm>.std::binary_searchused with only<algorithm>,<functional>, or<chrono>included: no error on this library version - add#include <algorithm>anyway when it is not the include already present, because the rescue is not guaranteed.std::lower_bound,std::upper_bound, orstd::equal_rangeused without<algorithm>in the lean context: the message names that name, with no header note - add#include <algorithm>.std::ranges::binary_searchused without<algorithm>in the lean context: the message is'std::ranges' has not been declared- add#include <algorithm>.binary_searchused without thestd::qualifier,<algorithm>included, over raw pointers: the message is'binary_search' was not declared in this scope- qualify the name asstd::binary_search. Overstd::vectoriterators the same unqualified call compiles through argument-dependent lookup in the program probed here - qualify it anyway.
Checklist
- Check the include list of the file that names the search, not just the project. The include must be in that file, or in a header that file includes directly by design.
- Do not wait for a note or a suggestion naming the header. For this error, in the contexts probed here, GCC prints neither for
binary_search- take the fix from the name's home header,<algorithm>, instead. - Do not import the
std::swapfix into this error: in the probed set,<utility>fails here the same plain way as<limits>does. Split neighboring names by home header first. - 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 rescuestd::binary_searchat all, and the two headers that do rescue it do so only transitively. - One header per name the file uses:
std::vectorcomes from<vector>andstd::stringfrom<string>, even in a program whose subject is the search - andstd::binary_searchcomes from<algorithm>in return. - After the fix, confirm the program runs, not just that it compiles: the fixed programs here print
1for5present in the sorted vector, and0 1for the absent value3and the present value6.
Related guides
- 'std::lower_bound' Is Not a Member of 'std' Fix - the same missing-include shape for the lower binary-search bound in
<algorithm>: its sweep splits two ways like this guide's, but its rescue list is far longer, and its textbook file is rescued where this guide's is not. - 'std::upper_bound' Is Not a Member of 'std' Fix - the same missing-include shape for the upper binary-search bound in
<algorithm>: its sweep shares this guide's two transitive rescues, but its error picks up adid you mean 'lower_bound'?suggestion in eleven probed contexts where this guide's error stays plain everywhere probed. - 'std::equal_range' Is Not a Member of 'std' Fix - the same missing-include shape for the pair of bounds in
<algorithm>that bracket the elements equal to a value, built from the same two bounds this guide links to. - 'std::sort' Is Not a Member of 'std' Fix - the same missing-include shape for the sorting function template in
<algorithm>, an older sibling in this family whose own guide covers its error and its fix. - 'std::find' Is Not a Member of 'std' Fix - the same missing-include shape for the linear-search function template in
<algorithm>, an older sibling in this family.
Sources
- cppreference,
std::binary_search— forstd::binary_searchbeing a function template defined in<algorithm>that checks whether an element equivalent tovalueexists in the partitioned range[first, last)- an element that neither orders before nor orders aftervalue- returningtrueif such an element exists andfalseotherwise, with one overload ordering byoperator<(bystd::less{}since C++20) and a second overload ordering by a comparatorcomp, both overloadsconstexprsince C++20, at most log2(N)+O(1) comparisons, the range needing only to be partitioned with respect tovaluethough it is usually sorted, andstd::lower_boundbeing the tool for obtaining an iterator to the element instead. - cppreference, Standard library header
<algorithm>— for<algorithm>being the header that declaresstd::binary_searchand the neighboring algorithm names, including thestd::ranges::binary_searchalgorithm function object since C++20. - cppreference,
std::lower_bound— forstd::lower_boundbeing a function template defined in<algorithm>that returns an iterator to the first element not less than the value. - cppreference,
std::upper_bound— forstd::upper_boundbeing a function template defined in<algorithm>that returns an iterator to the first element greater than the value. - cppreference,
std::equal_range— forstd::equal_rangebeing a function template defined in<algorithm>that returns the pair of bounds bracketing the elements equal to the value.
Keep Exploring
Seven tips and seven puzzles so far, each one a short runnable example with the fix explained.
Paste an AddressSanitizer, UBSan, or ThreadSanitizer report and get the bug, the file and line, and the fix \u2014 in plain language.
C++20 and C++23 features, migration paths, and measured trade-offs.
The full C++ hub \u2014 language basics, the standard library, coroutines, and measured comparisons.
Paste a [Service] section and get a plain-language verdict on every sandboxing setting it finds.