I\'ve recently posted a general question about RAII at SO. However, I still have some implementation issues with my HANDLE example.
A HANDLE
is typedeff
Don't bother with shared_ptr for that, use ATL::CHandle.
Here is why:
CHandle
you know that it's a RAII wrapper for a handle.shared_ptr
you don't know what it is.CHandle
doesn't make an ownership shared (however in some cases you may want a shared ownership).CHandle
is a standard for a windows development stack.CHandle
is more compact than shared_ptr
with custom deleter (less typing/reading).