View Single Post
  #5  
Old 06-11-2024, 13:45
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
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.


Quote:
Originally Posted by atom0s View Post
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:
__________________
AKA Solomon/blowfish.
Reply With Quote
The Following 2 Users Say Thank You to WhoCares For This Useful Post:
sendersu (06-11-2024), SofTw0rm (06-11-2024)