4 ms·
My intention is not to nitpick but I am genuinely trying to understand this from a pedantic perspective. > C++ has a neat feature called Resource acquisition i
by foo101 9y ago
My intention is not to nitpick but I am genuinely trying to understand this from a pedantic perspective.
> C++ has a neat feature called Resource acquisition is initialization, a.k.a RAII.
Is this really a feature of C++, or is this a design pattern/best practice that developers have discovered and use to write safer C++ code?
- Merad 9y agoA bit of both, IMO. RAII is a design pattern, not a language feature. However, it’s a pattern made possible by the semantics of destructors and object lifetimes in C++. The creator of C++ (Stroustrup) developed RAII within the first few years of the language’s existence.
- ovao 9y agoIt's not a discovery per se, since its creation was deliberate, but it's a practice exercised throughout the STL (the C++ standard template library), and is a term coined by C++ creator Bjarne Stroustrup himself. It could be considered a "standard pattern" in lieu of a better term.
- pjmlp 9y agoIt is a bit of both, as replied on siblling comments. While RAII was coined by the C++ community, it is not unique to C++, there are other languages that support it.