C++

'make_heap' Is Not a Member of 'std' Fix

std::make_heap lives in one header, <algorithm> - and on this library version almost no ordinary file rescues it by accident: in the sweep probed here, covering all 106 standard headers in the library's header set, only <functional>, <chrono>, <execution>, <queue>, <regex>, and <valarray> 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 takes one shape - the plain error, with no suggestion tail behind any probed header - or a transitive rescue. 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 · 21 min read

By the end of this guide
  • The error: the include is missing, in a lean file
  • The textbook version fails too - plainly
  • Neighboring headers: which ones fail plainly, which ones rescue it
  • The fix

Written December 1, 2026

Tested with GCC 13.3.0

What this guide is

std::make_heap is a function template defined in the header <algorithm>. It constructs a heap out of the range [first, last): with the plain overload the heap is ordered by operator< (since C++20, by std::less{}), so the largest element moves to the front, and the comparator overload builds the heap with respect to the comparison the program passes instead. It returns nothing. Both overloads are constexpr since C++20. Its iterators must be random-access iterators, and it makes at most 3N comparisons, where N is the length of the range. There is no execution-policy overload of std::make_heap - unlike the sorting algorithms, the heap algorithms were not given parallel overloads, and the fixed-programs section below shows what passing a policy does instead.

Because the template lives in one specific header, 'make_heap' 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 never prints a note naming <algorithm>, and it never prints note lines, help lines, or a suggestion tail under the error - behind every failing sole header in the sweep the diagnostic is the plain error line and its caret block, nothing more. The neighboring names probed here - std::push_heap, std::pop_heap, std::sort_heap, and std::is_heap, all in the same header - get no suggestion either 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. The sweep probed here 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 compile error or a transitive rescue, with no suggestion class at all. That is narrower than its closest siblings in this family: std::partial_sort carries a partial_sum suggestion tail behind 2 failing headers, and std::nth_element carries one behind 51. The rescue side is almost the family pattern - the same five headers that rescue those neighbors, plus one more: <queue>, whose std::priority_queue is built on the heap algorithms, pulls this name in too. The older siblings in this family - std::partial_sort, std::nth_element, std::rotate, std::partition, and std::sort - 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 builds a heap over an array with std::make_heap and returns success if the largest element, 6, lands at the front, but includes only <limits>:

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

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:

C++
int main() {
    int a[] = {5, 1, 4, 2, 3, 6};
    std::make_heap(a, a + 6);
    return a[0] == 6 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 n_none.cpp -o n_none_prog
n_none.cpp: In function 'int main()':
n_none.cpp:3:10: error: 'make_heap' is not a member of 'std'
    3 |     std::make_heap(a, a + 6);
      |          ^~~~~~~~~

The textbook version fails too - plainly

The version most often written first - build a heap over a vector and print its front element, with std::cout - gets the same error, without <algorithm>:

C++
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(v.begin(), v.end());
    std::cout << v[0] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 t_textbook.cpp -o t_textbook_prog
t_textbook.cpp: In function 'int main()':
t_textbook.cpp:5:10: error: 'make_heap' is not a member of 'std'
    5 |     std::make_heap(v.begin(), v.end());
      |          ^~~~~~~~~

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 - and here the error is plain, with no suggestion tail at all. In the sweep probed here, the only headers that rescue std::make_heap are <functional>, <chrono>, <execution>, <queue>, <regex>, and <valarray>, besides <algorithm> itself, and that rescue is a property of this library version, not a rule of the language. A program that uses std::make_heap includes <algorithm>, whether or not it happens to compile without it.

Neighboring headers: which ones fail plainly, which ones 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 builds a heap over an array and returns whether the front element holds 6, 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. These 99 headers fail with the plain is not a member of 'std' error, with no suggestion, no note, and no help:

  • <any>
  • <array>
  • <atomic>
  • <barrier>
  • <bit>
  • <bitset>
  • <cassert>
  • <ccomplex>
  • <cctype>
  • <cerrno>
  • <cfenv>
  • <cfloat>
  • <charconv>
  • <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>
  • <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 the same plain way. No failing sole header adds a suggestion tail - the suggestion class for this name is empty.

A sole <vector> file shows the plain shape in full:

C++
#include <vector>
int main() {
    int a[] = {5, 1, 4, 2, 3, 6};
    std::make_heap(a, a + 6);
    return a[0] == 6 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 v_vector.cpp -o v_vector_prog
v_vector.cpp: In function 'int main()':
v_vector.cpp:4:10: error: 'make_heap' is not a member of 'std'
    4 |     std::make_heap(a, a + 6);
      |          ^~~~~~~~~

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

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

Two contrasts with the neighboring sweeps are worth holding on to. First, there is no link-failure shape in this sweep: every failing sole header fails at compile time with the error above, 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, the rescue set carries one header the sorting neighbors do not: <queue>. Its class template std::priority_queue is implemented on top of the heap algorithms, and on this library version including it pulls std::make_heap in on the side - still a transitive accident, not a declaration to rely on. <algorithm> - the home header - is on the rescue 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:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(v.begin(), v.end());
    std::cout << v[0];
    for (int x : v) std::cout << " " << x;
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 h_fixed.cpp -o h_fixed_prog
$ ./h_fixed_prog
6 6 3 5 2 1 4

One include, <algorithm>, declares the template. Building a heap over 5, 1, 4, 2, 3, 6 puts the largest value, 6, at the front, and rearranges the rest into heap order 6, 3, 5, 2, 1, 4, so the program prints 6 followed by the full contents 6 3 5 2 1 4.

The fixed programs: the heap property, checked element by element

The heap property is exact, not just the right value at the front: after std::make_heap, every element is at least as large as both of its heap children - the elements at positions 2i + 1 and 2i + 2 - which this program checks element by element, alongside std::is_heap, and reports as 1, alongside the front element:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(v.begin(), v.end());
    bool ok = (v[0] == 6) && std::is_heap(v.begin(), v.end());
    for (std::size_t i = 0; i < v.size(); ++i) {
        std::size_t l = 2 * i + 1, r = 2 * i + 2;
        if (l < v.size()) ok = ok && (v[i] >= v[l]);
        if (r < v.size()) ok = ok && (v[i] >= v[r]);
    }
    std::cout << ok << " " << v[0] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 k_values.cpp -o k_values_prog
$ ./k_values_prog
1 6

The comparator overload orders by the comparison the program passes instead: with std::greater<int>() from <functional>, the heap is a min heap - the smallest value, 1, sits at the front, and std::is_heap under the same comparator confirms the property, so the program prints 1 1:

C++
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(v.begin(), v.end(), std::greater<int>());
    bool ok = std::is_heap(v.begin(), v.end(), std::greater<int>());
    std::cout << ok << " " << v[0] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 j_comp.cpp -o j_comp_prog
$ ./j_comp_prog
1 1

There is no execution-policy version to run. Passing std::execution::par as a first argument does not select a parallel overload, because none exists - the call fails with no matching function for call to 'make_heap', and the notes list the only two candidates there are, the plain overload and the comparator overload:

C++
#include <algorithm>
#include <execution>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(std::execution::par, v.begin(), v.end());
    std::cout << v[0] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 j_policy.cpp -o j_policy_prog
j_policy.cpp: In function 'int main()':
j_policy.cpp:7:19: error: no matching function for call to 'make_heap(const __pstl::execution::v1::parallel_policy&, std::vector<int>::iterator, std::vector<int>::iterator)'
    7 |     std::make_heap(std::execution::par, v.begin(), v.end());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algo.h:61,
                 from /usr/include/c++/13/algorithm:61,
                 from j_policy.cpp:1:
/usr/include/c++/13/bits/stl_heap.h:375:5: note: candidate: 'template<class _RAIter> constexpr void std::make_heap(_RAIter, _RAIter)'
  375 |     make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~
/usr/include/c++/13/bits/stl_heap.h:375:5: note:   template argument deduction/substitution failed:
j_policy.cpp:7:19: note:   deduced conflicting types for parameter '_RAIter' ('__pstl::execution::v1::parallel_policy' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
    7 |     std::make_heap(std::execution::par, v.begin(), v.end());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_heap.h:402:5: note: candidate: 'template<class _RAIter, class _Compare> constexpr void std::make_heap(_RAIter, _RAIter, _Compare)'
  402 |     make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~~~
/usr/include/c++/13/bits/stl_heap.h:402:5: note:   template argument deduction/substitution failed:
j_policy.cpp:7:19: note:   deduced conflicting types for parameter '_RAIter' ('__pstl::execution::v1::parallel_policy' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
    7 |     std::make_heap(std::execution::par, v.begin(), v.end());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So a heap is built with the plain or comparator call, in the program's own thread; there is no policy argument to add, and <execution> is needed only for code that uses a policy with an algorithm that actually takes one.

The neighboring names: same header, plain in the lean context

The names that std::make_heap is built alongside share its home header. In the lean context here - only <limits> included - they get no suggestion at all. std::push_heap - the function template defined in <algorithm> that adds the element at the end of a heap range back into the heap - gets its own error, again with no header note:

C++
#include <limits>
int main() {
    int a[] = {5, 1, 4, 2, 3, 6};
    std::push_heap(a, a + 6);
    return a[0] == 6 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 b_push.cpp -o b_push_prog
b_push.cpp: In function 'int main()':
b_push.cpp:4:10: error: 'push_heap' is not a member of 'std'
    4 |     std::push_heap(a, a + 6);
      |          ^~~~~~~~~

std::pop_heap - the function template defined in <algorithm> that moves the heap's front element to the end of the range and rebuilds the heap over the rest - fails the same way:

C++
#include <limits>
int main() {
    int a[] = {6, 5, 4, 2, 3, 1};
    std::pop_heap(a, a + 6);
    return a[5] == 6 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 c_pop.cpp -o c_pop_prog
c_pop.cpp: In function 'int main()':
c_pop.cpp:4:10: error: 'pop_heap' is not a member of 'std'
    4 |     std::pop_heap(a, a + 6);
      |          ^~~~~~~~

std::sort_heap - the function template defined in <algorithm> that turns a heap into a range sorted in ascending order - fails the same way:

C++
#include <limits>
int main() {
    int a[] = {6, 5, 4, 2, 3, 1};
    std::sort_heap(a, a + 6);
    return a[0] == 1 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 d_sortheap.cpp -o d_sortheap_prog
d_sortheap.cpp: In function 'int main()':
d_sortheap.cpp:4:10: error: 'sort_heap' is not a member of 'std'
    4 |     std::sort_heap(a, a + 6);
      |          ^~~~~~~~~

And std::is_heap - the function template defined in <algorithm> that reports whether a range is a heap - fails the same way, again with no header note:

C++
#include <limits>
int main() {
    int a[] = {6, 5, 4, 2, 3, 1};
    return std::is_heap(a, a + 6) ? 0 : 1;
}
Terminal
$ g++ -std=c++20 e_isheap.cpp -o e_isheap_prog
e_isheap.cpp: In function 'int main()':
e_isheap.cpp:4:17: error: 'is_heap' is not a member of 'std'
    4 |     return std::is_heap(a, a + 6) ? 0 : 1;
      |                 ^~~~~~~

One contrast is worth holding on to: in the lean programs here, make_heap, push_heap, pop_heap, sort_heap, and is_heap all get no note and no suggestion. Do not read the absence of a suggestion as a puzzle - in this probed set the fix comes from the names' home, <algorithm>, either way.

The neighboring names, fixed

And the neighboring names work under the same one added header: building a heap puts 6 at the front and std::is_heap confirms it, popping the heap moves that 6 to the back, pushing 7 and sorting the heap leaves the range sorted ascending, 1 first and 7 last:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::make_heap(v.begin(), v.end());
    int top = v[0];
    bool h = std::is_heap(v.begin(), v.end());
    std::pop_heap(v.begin(), v.end());
    int popped = v.back(); v.pop_back();
    v.push_back(7); std::push_heap(v.begin(), v.end());
    std::sort_heap(v.begin(), v.end());
    std::cout << top << " " << h << " " << popped << " " << v[0] << " " << v[5] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 k_neighbors_fixed.cpp -o k_neighbors_fixed_prog
$ ./k_neighbors_fixed_prog
6 1 6 1 7

Since C++20 the same <algorithm> header also declares std::ranges::make_heap, the ranges form of the same heap construction. It comes in two call shapes - an iterator pair, and a single range - and returns the past-the-end iterator of the range: here both shapes put 6 at the front and return the end iterator, printing 6 1 6 1. 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:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    std::vector<int> w = {5, 1, 4, 2, 3, 6};
    auto e1 = std::ranges::make_heap(v.begin(), v.end());
    auto e2 = std::ranges::make_heap(w);
    std::cout << v[0] << " " << (e1 == v.end()) << " " << w[0] << " " << (e2 == w.end()) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 r_ranges.cpp -o r_ranges_prog
$ ./r_ranges_prog
6 1 6 1
C++
#include <limits>
int main() {
    int a[] = {5, 1, 4, 2, 3, 6};
    std::ranges::make_heap(a, a + 6);
    return a[0] == 6 ? 0 : 1;
}
Terminal
$ 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:10: error: 'std::ranges' has not been declared
    4 |     std::ranges::make_heap(a, a + 6);
      |          ^~~~~~

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:

C++
#include <algorithm>
int main() {
    int a[] = {5, 1, 4, 2, 3, 6};
    make_heap(a, a + 6);
    return a[0] == 6 ? 0 : 1;
}
Terminal
$ 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:5: error: 'make_heap' was not declared in this scope
    4 |     make_heap(a, a + 6);
      |     ^~~~~~~~~
g2_unqualified_ptr.cpp:4:5: note: suggested alternatives:
In file included from /usr/include/c++/13/bits/stl_algo.h:61,
                 from /usr/include/c++/13/algorithm:61,
                 from g2_unqualified_ptr.cpp:1:
/usr/include/c++/13/bits/stl_heap.h:402:5: note:   'std::make_heap'
  402 |     make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:1678:35: note:   'std::ranges::make_heap'
 1678 |   inline constexpr __make_heap_fn make_heap{};
      |                                   ^~~~~~~~~

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 notes do name the right names - the first points at std::make_heap itself, shown at its comparator declaration in the internal header the transcript names, and the second at std::ranges::make_heap. Qualify the name as std::make_heap; 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 6:

C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v = {5, 1, 4, 2, 3, 6};
    make_heap(v.begin(), v.end());
    std::cout << v[0] << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 g_unqualified.cpp -o g_unqualified_prog
$ ./g_unqualified_prog
6

What happened: the iterators belong to namespace std, so argument-dependent lookup finds std::make_heap 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::make_heap is declared by #include <algorithm>, and by no other header by rule. In the sweep probed here, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , do not declare it, and neither does a file with no include at all.
  • 'make_heap' is not a member of 'std' means the <algorithm> include is missing and nothing else in the file pulled the name in. In the contexts probed here, GCC prints no note naming <algorithm>, no note lines, no help lines, and no suggestion tail under it - the suggestion class in the probed set is empty.
  • In the sweep probed here, the split is two-way: a sole header either fails plainly or rescues the program. No probed sole header produces a declared-but-not-defined link-failure shape for this name.
  • In the sweep probed here, only six headers besides <algorithm> rescue std::make_heap transitively - <functional>, <chrono>, <execution>, <queue>, <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, those headers are not required to pull std::make_heap in.
  • std::make_heap has only the plain and comparator overloads, both constexpr since C++20, and no execution-policy overload: passing a policy fails with no matching function for call to 'make_heap', with the two existing overloads listed as the candidates.
  • std::push_heap, std::pop_heap, std::sort_heap, and std::is_heap are declared by the same #include <algorithm>: in the programs shown here, which include only <limits> beside the use, each gets its own is not a member of 'std' error when that include is missing, with no header note and no suggestion.
  • std::ranges::make_heap is declared by the same #include <algorithm> since C++20: with the include it builds the heap and returns the past-the-end iterator, in both its iterator-pair and its single-range call shapes, and in the lean context probed here it gets the error 'std::ranges' has not been declared when that include is missing.
  • 'make_heap' was not declared in this scope for an unqualified make_heap use over raw pointers is a different defect: qualify the name as std::make_heap - the include alone does not bring the name out of namespace std. The same unqualified use over std::vector iterators 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::make_heap. If <algorithm> is not there, add it - that is the fix in the common case, and it holds whether the file failed plainly or happened to compile before through a transitive rescue.
  • Second, do not wait for a suggestion or a note naming the header. For this error, in the contexts probed here, GCC prints neither - take the fix from the name's home header, <algorithm>, instead.
  • Third, do not reach for <utility> because the error sentence looks like the std::swap error. In the sweep probed here, <utility> as the only include fails plainly with the same 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>, <chrono>, <execution>, <queue>, <regex>, and <valarray> rescue it, and that rescue is not guaranteed.
  • Fifth, do not add an execution policy to the call. There is no policy overload of std::make_heap to select - the call fails with no matching function for call to 'make_heap' - so build the heap with the plain or comparator overload.
  • Sixth, if the error says was not declared in this scope instead, fix the name's qualifier to std::make_heap as well - and do not rely on an unqualified call that happens to compile over std iterators, because the same call over raw pointers fails.
  • Seventh, if the failing name is a neighboring one, check its header before fixing: push_heap, pop_heap, sort_heap, and is_heap take the same added <algorithm>, while swap takes <utility>.

Which fix for which cause

  • #include <algorithm> missing, std::make_heap used in a file whose only include is one of the 99 headers listed as plain in the sweep section above, or that includes nothing: the message is 'make_heap' is not a member of 'std', with no suggestion, no header note, and no help - add #include <algorithm>.
  • std::make_heap used in a textbook file including <iostream> and <vector>: the message is the same error, plainly, with no suggestion tail - add #include <algorithm>.
  • std::make_heap used with only <algorithm>, <functional>, <chrono>, <execution>, <queue>, <regex>, or <valarray> 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::make_heap called with an execution policy as its first argument, <algorithm> included: the message is no matching function for call to 'make_heap' - remove the policy; only the plain and comparator overloads exist.
  • std::push_heap, std::pop_heap, std::sort_heap, or std::is_heap used without <algorithm> in the lean context: the message names that name, plainly, with no header note - add #include <algorithm>.
  • std::ranges::make_heap used without <algorithm> in the lean context: the message is 'std::ranges' has not been declared - add #include <algorithm>.
  • make_heap used without the std:: qualifier, <algorithm> included, over raw pointers: the message is 'make_heap' was not declared in this scope - qualify the name as std::make_heap. Over std::vector iterators 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 heap construction, 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 suggestion or a note naming the header. For this error, in the contexts probed here, GCC prints no suggestion tail and no note naming <algorithm> - take the fix from the name's home header, <algorithm>, instead.
  • Do not import the std::swap fix into this error: in the probed set, <utility> fails here too, plainly. 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 rescue std::make_heap at all, and the six headers that do rescue it do so only transitively.
  • One header per name the file uses: std::vector comes from <vector> and std::string comes from <string>, even in a program whose subject is the heap - and std::make_heap comes from <algorithm> in return. The comparator overload's std::greater comes from <functional>, and there is no execution-policy overload to take <execution> for.
  • After the fix, confirm the program runs, not just that it compiles: the fixed programs here print 6 6 3 5 2 1 4 for the front element and the full heap contents, and 1 6 for the heap-property check and the front element it found.
  • 'std::partial_sort' Is Not a Member of 'std' Fix - the same missing-include shape for the partial sorting function template in <algorithm>: its full header sweep splits three ways with a suggestion tail behind 2 failing headers, where this guide's sweep has no suggestion class at all, and its rescue set lacks this guide's extra <queue>.
  • 'std::nth_element' Is Not a Member of 'std' Fix - the same missing-include shape for the single-position partitioning function template in <algorithm>, an older sibling in this family whose own guide covers its error and its fix.
  • 'std::sort' Is Not a Member of 'std' Fix - the same missing-include shape for the full sorting function template in <algorithm>, an older sibling in this family whose own guide covers its error and its fix.
  • 'std::partition' Is Not a Member of 'std' Fix - the same missing-include shape for the predicate reordering in <algorithm>, an older sibling in this family whose own guide covers its error and its fix.

Sources

  • cppreference, std::make_heap — for std::make_heap being a function template defined in <algorithm> that constructs a heap out of [first, last), with the plain overload ordered by operator< (since C++20, std::less{}) and a comparator overload, both constexpr since C++20, random-access iterators required, at most 3N comparisons, and no execution-policy overload listed.
  • cppreference, Standard library header <algorithm> — for <algorithm> being the header that declares std::make_heap and the neighboring algorithm names, including the std::ranges::make_heap algorithm function object since C++20.
  • cppreference, std::ranges::make_heap — for std::ranges::make_heap being an algorithm function object defined in <algorithm> since C++20, constexpr, in an iterator-sentinel form and a range form, that constructs the same heap and returns the past-the-end iterator of the range.
  • cppreference, std::push_heap — for std::push_heap being a function template defined in <algorithm> that adds an element to a heap.
  • cppreference, std::pop_heap — for std::pop_heap being a function template defined in <algorithm> that removes the largest element from a heap.
  • cppreference, std::sort_heap — for std::sort_heap being a function template defined in <algorithm> that turns a heap into a range of elements sorted in ascending order.
  • cppreference, std::is_heap — for std::is_heap being a function template defined in <algorithm> that checks whether a range is a heap.

Keep Exploring