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.

Properly terminating program. Using exceptions

Question: Is using exceptions the proper way to terminate my program if all I want is to display an error …

c++ exception raii idioms
C++ Arrays and make_unique

As a follow up to this post I wonder how its implementation of make_unique plays with allocating function-temporary buffer …

c++ arrays c++11 unique-ptr raii
Move constructor and const member variables

I like the idea of const member variables especially when I wrap C functions into classes. The constructor takes a …

c++11 raii move-constructor
Implementing RAII in C#

I have an InfoPath form which I need to conditionally disable it's OnChange events. Since it's not possible to bind …

c# raii
Why is there no RAII in .NET?

Being primarily a C++ developer the absence of RAII (Resource Acquisition Is Initialization) in Java and .NET has always bothered …

.net struct destructor raii value-type
Is a C++ destructor guaranteed not to be called until the end of the block?

In the C++ code below, am I guaranteed that the ~obj() destructor will be called after the // More code executes? …

c++ raii
RAII vs. exceptions

The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (…

c++ exception raii destructor
What is the best way to implement smart pointers in C++?

I've been evaluating various smart pointer implementations (wow, there are a LOT out there) and it seems to me that …

c++ smart-pointers c++03 raii reference-counting
Making a HANDLE RAII-compliant using shared_ptr with a custom deleter

I've recently posted a general question about RAII at SO. However, I still have some implementation issues with my HANDLE …

c++ winapi raii
Do programmers of other languages, besides C++, use, know or understand RAII?

I've noticed RAII has been getting lots of attention on Stackoverflow, but in my circles (mostly C++) RAII is so …

c++ language-agnostic raii