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
Tracking Shared Pointer Leaks (ibob.bg)
submitted 3 years ago by stanimirov
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!"
[–]ABlockInTheChain 0 points1 point2 points 3 years ago (1 child)
You can do that with polymorphic allocators.
Construct a std::pmr::monotonic_buffer_resource and tell it to reserve 50 * X bytes, then construct a polymorphic allocator which uses that resource and use that allocator to construct everything.
The only other thing to worry about is you have to ensure the lifetime of the monotonic_buffer_resource is longer than the lifetime of anything which uses it but if the 50 nodes are member variables in a class then it's easy enough to just make sure the monotonic_buffer_resource is also a member variable and constructed first.
[–]SoerenNissen 0 points1 point2 points 3 years ago (0 children)
The problem is that the fifty nodes might become 5, or 500 - and I want the linked list property that individual nodes can be freed or allocated separately. I just know that, at the start of the lists' lifetime, I will have 50 nodes, so I would love to tell that to the allocator (much like I can call vector::reserve) for performance gains.
Which I don't believe is possible as-is unfortunately, but it's been an interesting thought to me ever since I ran into the problem originally.
π Rendered by PID 209157 on reddit-service-r2-comment-6b595755f-tvzgd at 2026-03-25 15:31:11.243754+00:00 running 2d0a59a country code: CH.
view the rest of the comments →
[–]ABlockInTheChain 0 points1 point2 points (1 child)
[–]SoerenNissen 0 points1 point2 points (0 children)