Top "Raii" questions

Resource Acquisition Is Initialization (RAII) is a common idiom used in C++ to manage the lifetime of resources, including memory allocations, file handles or database connections.

Does C++ support 'finally' blocks? (And what's this 'RAII' I keep hearing about?)

Does C++ support 'finally' blocks? What is the RAII idiom? What is the difference between C++'s RAII idiom and …

c++ exception raii finally c++-faq
General guidelines to avoid memory leaks in C++

What are some general tips to make sure I don't leak memory in C++ programs? How do I figure out …

c++ memory memory-management raii
throwing exceptions out of a destructor

Most people say never throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes …

c++ exception destructor raii
C++ read the whole file in buffer

What is a good approach to read the whole file content in a buffer for C++? While in plain C …

c++ raii
What is meant by Resource Acquisition is Initialization (RAII)?

What is meant by Resource Acquisition is Initialization (RAII)?

c++ raii
Do I need to manually close an ifstream?

Do I need to manually call close() when I use a std::ifstream? For example, in the code: std::string …

c++ ifstream raii
RAII and smart pointers in C++

In practice with C++, what is RAII, what are smart pointers, how are these implemented in a program and what …

c++ smart-pointers raii
Why is it wrong to use std::auto_ptr<> with standard containers?

Why is it wrong to use std::auto_ptr<> with standard containers?

c++ stl raii auto-ptr c++-faq
RAII tutorial for C++

I'd like to learn how to use RAII in c++. I think I know what it is, but have no …

c++ raii
How to initialize an object using async-await pattern

I'm trying to follow RAII pattern in my service classes, meaning that when an object is constructed, it is fully …

c# design-patterns ninject async-await raii