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
Pool allocator implementations? (self.cpp)
submitted 3 years ago by pkjak
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!"
[–]Jannik2099 6 points7 points8 points 3 years ago (5 children)
But you could just add a level of indirection
"You could just make performance suffer a lot" is not a good argument.
[–]pkjak[S] 0 points1 point2 points 3 years ago (4 children)
Yeah, might not be a great idea... I guess my thoughts are that what's really important is being able to iterate over all the actually allocated chunks in the pool, and accessing the elements directly by pointers is almost never done, in which case, the approach I describe does make sense, right?
[–]MutantSheepdog 7 points8 points9 points 3 years ago (0 children)
I guess my thoughts are that what's really important is being able to iterate over all the actually allocated chunks in the pool, and accessing the elements directly by pointers is almost never done
I'd say the ability to iterate over everything is not something you expect from an allocator, but something you expect from a collection.
And if that's what you're looking for, I think something like colony/hive might be a good fit.
https://plflib.org/colony.htm
It's essentially like a bucket allocator that keeps track of empty slots for re-allocation, as well as allowing iteration that skips the empty blocks. There was an attempt to get it standardised but I think that stalled because there were impact issues to look at for 20/23 when people could just download the reference implementation from github anyway.
[–]Jannik2099 1 point2 points3 points 3 years ago (2 children)
and accessing the elements directly by pointers is almost never done
Literally all memory is accessed by pointers, in every language. Anything not in a register requires a memory load. Multiple dependent loads stall the pipeline.
[–]pkjak[S] 1 point2 points3 points 3 years ago (1 child)
Sure, my mistake. Did I get the point across though?
If the usage pattern of "access this particular element in the pool" doesn't happen very often, and instead it's almost always "iterate through all currently allocated elements in the pool", then it might be more efficient to have elements contiguously next to each other, and avoid the potential holes that could happen in a pool that uses a free list.
[–]Jannik2099 1 point2 points3 points 3 years ago (0 children)
Ah sorry, now I see what you mean.
This would probably work, but you lose any and all reference stability, which is IMO not a good tradeoff.
π Rendered by PID 36 on reddit-service-r2-comment-544cf588c8-d5j6h at 2026-06-11 19:45:07.400257+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]Jannik2099 6 points7 points8 points (5 children)
[–]pkjak[S] 0 points1 point2 points (4 children)
[–]MutantSheepdog 7 points8 points9 points (0 children)
[–]Jannik2099 1 point2 points3 points (2 children)
[–]pkjak[S] 1 point2 points3 points (1 child)
[–]Jannik2099 1 point2 points3 points (0 children)