M
Michael Tsang
In C++, everything should be acquired and initialised in constructors and
released in destructors but I'm in a trouble trying to do this. Nearly all
code written by me requires interacting with C libraries, most commonly
POSIX so I am forced to scatter my code with open(), close(), opendir(),
closedir(), fdopen(), pipe(), mmap(), etc inside middle of functions and it
is very difficult to get it right when the code throws exceptions. I know
that RAII is the only way to prevent leaking non-memory resources such as
file handles.
released in destructors but I'm in a trouble trying to do this. Nearly all
code written by me requires interacting with C libraries, most commonly
POSIX so I am forced to scatter my code with open(), close(), opendir(),
closedir(), fdopen(), pipe(), mmap(), etc inside middle of functions and it
is very difficult to get it right when the code throws exceptions. I know
that RAII is the only way to prevent leaking non-memory resources such as
file handles.