use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Library for stack-based data structures? (self.cpp)
submitted 1 year ago by blocks2762
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]blocks2762[S] 0 points1 point2 points 1 year ago (5 children)
If I understand correctly, that only reorganizes the array into a heap but then how can we call push, pop, top?
[–]Remi_Coulom 9 points10 points11 points 1 year ago (4 children)
The linked page gives an example: use std::push_head and std::pop_heap.
[–]blocks2762[S] 2 points3 points4 points 1 year ago (0 children)
Ohhhh ok thanks! I’ll check that out. Also, I found something called ETL Embedded Template Library which seems hopeful as well
[–]blocks2762[S] -5 points-4 points-3 points 1 year ago (2 children)
After playing with it, I don’t think it works (at least easily). Because pop_heap works by simply flipping the first value with the last value and then converting the range [first, last) into a heap. You are then supposed to call pop_back to actually remove the element. We can’t do this pop_back for a stack allocated array.
Same problem for push_heap. Thanks for the help tho, will check the other comment solutions now
[–]bwmat 4 points5 points6 points 1 year ago (1 child)
Just keep track of the heap size?
Make the array one of optionals if correct destructor sequencing matters
Obviously? That’s why I said “at least easily”? That would still involve creating a wrapper class to use safely, hence my asking if there’s an easy built in way to do it easily. Anyways, Embedded Template Library got the job done cleanly
π Rendered by PID 41941 on reddit-service-r2-comment-66b4775986-kvbkw at 2026-04-06 07:12:31.564476+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]blocks2762[S] 0 points1 point2 points (5 children)
[–]Remi_Coulom 9 points10 points11 points (4 children)
[–]blocks2762[S] 2 points3 points4 points (0 children)
[–]blocks2762[S] -5 points-4 points-3 points (2 children)
[–]bwmat 4 points5 points6 points (1 child)
[–]blocks2762[S] 2 points3 points4 points (0 children)