[Development] Use RAII for non-pointer resources
Konstantin Tokarev
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:
https://accu.org/index.php/journals/2086
>
> Please see:
>
> [1] http://stackoverflow.com/questions/22775500/is-there-any-raii-file-handle-already-implemented
> [2] http://stackoverflow.com/questions/24611215/one-liner-for-raii-on-non-pointer
> [3] http://stackoverflow.com/questions/14841396/stdunique-ptr-deleters-and-the-win32-api
>
> and soo on. :)
>
> BR,
> Denis
> ,
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
--
Regards,
Konstantin
More information about the Development
mailing list