
2017-03-21 15:04 GMT+08:00 Andrey Davydov via Boost
I have implemented smart pointer with semantics of unique ownership and type erased deleter (https://github.com/AndreyG/unnamed). It has size of 3 pointers and it doesn't require additional memory allocations for the case when deleter is empty class (for example, std::default_delete or non-capturing lambda) and for the case when deleter is known at compile time function (for instance, fclose). The are some simple examples of usage and tests in the repo.
Why don't just use unique_ptr
>? The main reason is that due to the small object optimization std::function has rather big size. For instance, sizeof(unique_ptr >) == 72 for MSVC x64! Results for the other platforms can be found in the repo README. Does it seem useful?
Why not:
```
template<class T>
using my_ptr = unique_ptr