News for hackers. Stuff that matters.
Re:Modern C++ – RAII by majoe on Friday May 30, 2025 @07:38AM (#44135163)
Reasons I can think of:

- Wrapping all objects in shared pointer is annoying. - If you stick to that convention, you have to do it on every call side, while you only have to implement RAII once. - You can enforce invariants of your class with RAII, that you can't with a plain shared_ptr - Regarding efficiency: It has the overhead of reference counting plus you have to store all objects on the heap instead of the stack. In hot loops this may hurt cache locality.

There are no comments on this comment yet.