0

So I recently learned of the make_heap function. Thinking. Oh, that is a nice way of creating multiple heaps which can be used as a memory resource for new.

But after reading more about make_heap it is something completly different from the normal heap.

What is the reasoning behind these naming conventions? Because AFAIK they are something completly different.

Daan Timmer
  • 14,239
  • 5
  • 32
  • 64
  • 1
    Because the C++ standard never refers to a heap in the first place the way you describe it. It refers to the free-store, that's it. The compiler implementation can decide how to implement this free store. It usually uses a heap but this is not required by the standard at all. `std::make_heap` does just that, it creates an actual heap structure. – Hatted Rooster Mar 16 '18 at 16:12
  • Related: https://stackoverflow.com/questions/947394/what-is-the-point-of-make-heap – drescherjm Mar 16 '18 at 16:13
  • 1
    @SombreroChicken: *"It usually uses a heap"* -- You mean, as in the heap data structure? This: https://en.wikipedia.org/wiki/Heap_(data_structure) ? -- I can't imagine why it would. But I'm not an expert in memory allocation algorithms. As far as I understood, this was always just a case of two unrelated things being given the same name. – Benjamin Lindley Mar 16 '18 at 16:19
  • 1
    @BenjaminLindley The older languages did, major compilers these days, not so much, you're right. Pool would be a better name nowadays. – Hatted Rooster Mar 16 '18 at 16:21
  • Thanks guys. I searched and searched but didn't find the answers you guys linked. Once more, thanks :-) Sorry for the duplicate question. – Daan Timmer Mar 17 '18 at 12:58

0 Answers0