Re:Why RAII rocks
by bmm6o on Thursday April 23, 2015 @04:14PM
(#9429512)
Even in cases like that it's uncommon for the object to actually take up a lot of stack space. Since member variable's sizes have to be known at compile time it only applies to fixed-size (or parametrized) buffers.
[ Parent
| on HN ]
As far as I know, using `new` or not has nothing to really do if it goes onto the stack or not. That's simply a common implementation details.
What its really saying is if the lifetime is automatic or manual.
Maybe I'm confusing C with C++ or just outright confused, but to my understanding, nothing says that:
int foo[] = <massive amount of data>;
actually has to live on the stack.Well, in practice, it's both. Sure, stacks and heaps are an implementation detail, but they're pervasive. You simply can't write int x[10000][10000]; and expect it to not cause a stack overflow in any real world implementation. It's an implementation detail you absolutely need to be aware of.