![]() |
|
|
|
#1
|
||||
|
||||
|
Using templates can remove the need to manually define the delete function. It can also be used to further extend into a custom wrapper to deal with the other parts you mentioned as well such as:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
__________________
Personal Projects Site: https://atom0s.com |
| The Following 3 Users Say Thank You to atom0s For This Useful Post: | ||
|
#2
|
||||
|
||||
|
Your coding a wrapper/aggregator for std::unique_ptr is a good choice.
Some types are same, but with different default values and different cleanup APIs. For OpenProcess()/OpenThreadToken() etc., the type is HANDLE, the default value is NULL, the cleanup API is CloseHandle(). For CreateFile()/FindFirstFile()/CreateToolhelp32Snapshot() etc., the type is also HANDLE, but the default value is INVALID_HANDLE_VALUE, and the cleanup API for FindFirstFile() is FindClose(), instead of CloseHandle(). So that's why I use traits/adapter to describe the difference. And, I need the operator&() override to auto reset to the default value when reusing the same UniqueResource variable.
__________________
AKA Solomon/blowfish. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Resource Manager (.NET) v2 | CodeCracker | Community Tools | 2 | 11-23-2025 22:25 |