[Development] Use RAII for non-pointer resources
annulen at yandex.ru
Sun Mar 12 20:13:16 CET 2017
12.03.2017, 17:24, "Denis Shienkov" <denis.shienkov at gmail.com>:
> Hi all,
> what do you think about using of RAII, e.g. for:
> * Windows: for HANDLE, HKEY and so on.
> * POSIX: for fd and so on.
> * OSX: for io_registry_entry_t and so on.
> As we use C++11 now everywhere, then, maybe can be to add appropriate
> RAII functionality e.g. to qcore_unix_p.h, qcore_win_p.h, qcore_mac_p.h files?
Note that unique_ptr with custom deleter is not a good fit for non-pointer resources.
Better approach is discussed here:
> Please see:
>  http://stackoverflow.com/questions/22775500/is-there-any-raii-file-handle-already-implemented
>  http://stackoverflow.com/questions/24611215/one-liner-for-raii-on-non-pointer
>  http://stackoverflow.com/questions/14841396/stdunique-ptr-deleters-and-the-win32-api
> and soo on. :)
> Development mailing list
> Development at qt-project.org
More information about the Development