Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you want GC shared_ptr is always available in C++. Sure, cyclic loops are always possible, but it is not something that happens often by mistake. In 15 year of professional work in C++ I've nerver seen them.

On the other hand lambdas would be significantly less useful if any use implied an allocation and GC was forced.

The issue with fstream is that if you really care about the error you call close explicitly, otherwise you let the destructor swallow it.

In fact if you really care about errors and you would use a transactional interface, with an explicit commit and a no-fail implicit rollback in the destructor. RAII works perfectly for that.

Regarding CPS, that's exactly what the new coroutines do. They end up heap allocating the stack frame, which has proven extremely contentious to say the least. Still, RAII works just fine there.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: