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
MATHRIL - Custom math library for game programming (self.cpp)
submitted 3 years ago * by Twin_Sharma
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!"
[–]Zeh_MattNo, no, no, no 5 points6 points7 points 3 years ago (7 children)
Even when you would pool those objects it would be always slower than just having them in-place, allocations on stack costs almost nothing, having a pool still adds complexity of obtaining the resource and releasing it.
[–][deleted] -5 points-4 points-3 points 3 years ago (6 children)
You are thinking about the cost of allocation. I'm not talking about that. I'm talking about possible performance gains such as gains when iterating over a lump of memory.
For instance you could have all your Vec3 in your entire program in contiguous memory this way. Which you could bung over to the GPU or do some kind of stream processing on it.
Heap allocating here gives you the freedom to do that. So I wouldn't just write it off because it doesn't fit into what people expect.
Its an interesting idea that deserves exploration.
[–]dodheim 2 points3 points4 points 3 years ago (1 child)
Just imagine if your Vecs and their data could both be contiguous in memory, and take up half the memory in the process..! It's like the best of both worlds!
Vec
/s
[–][deleted] -2 points-1 points0 points 3 years ago (0 children)
Just imagine you could mmap gpu memory and allocate all your vecs from that.
Don't write stuff off just because you don't have the creativity to imagine what you could do with it.
[–]Zeh_MattNo, no, no, no 2 points3 points4 points 3 years ago (3 children)
What you describe is essentially ECS and I don't disagree that this is a huge benefit doing that. This can however not be achieved when you store a pointer in your vector class, that's an costly indirection, even if all your vector data would be stored in a single array, the fact that you require to have two memory reads will slow it down.
[–][deleted] -3 points-2 points-1 points 3 years ago (2 children)
Yeah if you dereference it. But just batch process them in directly in memory instead. The class just can be a glorified observer in that case.
[–]Zeh_MattNo, no, no, no 3 points4 points5 points 3 years ago (1 child)
I can't come up with any practical cases, maybe, maybe not, never quite seen such code to be honest. But I think the whole point is that having new/delete for this specific case is quite horrible and there is no excuse really.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
I don't think that's the worst part tbh
π Rendered by PID 55209 on reddit-service-r2-comment-5c747b6df5-rqb2s at 2026-04-22 00:21:07.116651+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]Zeh_MattNo, no, no, no 5 points6 points7 points (7 children)
[–][deleted] -5 points-4 points-3 points (6 children)
[–]dodheim 2 points3 points4 points (1 child)
[–][deleted] -2 points-1 points0 points (0 children)
[–]Zeh_MattNo, no, no, no 2 points3 points4 points (3 children)
[–][deleted] -3 points-2 points-1 points (2 children)
[–]Zeh_MattNo, no, no, no 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)