skypjack / uvw

Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!
MIT License
1.87k stars 211 forks source link

Allow passing unique_ptr with any deleter #182

Closed purplesyringa closed 4 years ago

purplesyringa commented 4 years ago

Consider an external C function that allocates memory with malloc. I want to send the data over a TCP socket, but TCPHandle::write only accepts unique_ptr<char[], default_delete<char[]>>. Can passing a custom deleter be implemented?

skypjack commented 4 years ago

I think it's possible actually. Supporting all types of deleters can be tricky though while constraining the signature to something more specific may be easier to implement and work with. I've to try it though, so let's see. What do you suggest exactly? Is having a void(*)(char *) like deleter enough from your point of view?

skypjack commented 4 years ago

See if branch experimental is what you expect. Thanks. I'm looking forward to your feedback.

purplesyringa commented 4 years ago

Yes, it solves my problem. Thanks!