
What is meant by Resource Acquisition is Initialization (RAII)?
Feb 23, 2010 · In RAII, holding a resource is a class invariant, and is tied to object lifetime: resource allocation (or acquisition) is done during object creation (specifically initialization), by the constructor, …
c++ - Understanding the meaning of the term and the concept - RAII ...
Apr 22, 2014 · RAII, Resource Acquisition Is Initialization means that all acquired resources should be acquired in the context of the initialization of an object. This forbids "naked" resource acquisition.
RAII and smart pointers in C++ - Stack Overflow
Dec 27, 2008 · In practice with C++, what is RAII, what are smart pointers, how are these implemented in a program and what are the benefits of using RAII with smart pointers?
Implementing RAII in pure C? - Stack Overflow
Is it possible to implement RAII in pure C? I assume it isn't possible in any sane way, but perhaps is it possible using some kind of dirty trick. Overloading the standard free function comes to ...
c++ - RAII vs. Garbage Collector - Stack Overflow
Jun 2, 2017 · If I strictly follow RAII rules, which seems to be a good thing, why would that be any different from having a garbage collector in C++? I know that with RAII the programmer is in full …
RAII tutorial for C++ - Stack Overflow
Oct 17, 2013 · The reference that I personally have found most helpful on the topic of RAII is the book Exceptional C++ by Herb Sutter. Many of the topics covered in that book are touched on in the Guru …
Does C++ support 'finally' blocks? (And what's this 'RAII' I keep ...
No, C++ does not support 'finally' blocks. The reason is that C++ instead supports RAII: "Resource Acquisition Is Initialization" -- a poor name† for a really useful concept. The idea is that an object's …
What's RAII? Examples? - Software Engineering Stack Exchange
4 RAII is partly about deciding when an object becomes responsible for its own cleanup - the rule being that the object becomes responsible if and when its constructor initialisation completes. The …
c++ - RAII vs. exceptions - Stack Overflow
The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (finalization, however you want to call it) can fail, in which case exce...
c++ - Do I need to manually close an ifstream? - Stack Overflow
Apr 14, 2009 · NO This is what RAII is for, let the destructor do its job. There is no harm in closing it manually, but it's not the C++ way, it's programming in C with classes. If you want to close the file …