1974 shaares
6 private links
6 private links
C++11 and 14 provide a tool that expresses single ownership of a resource, unique_ptr. When the unique_ptr is deleted, such as when its parent container is destroyed or when it goes out of scope, a custom deleter can be called instead of the delete operator. This behavior is exactly the right mix for managing a resource created by a C library.
An example of a typefree printf with variadic templates: http://en.cppreference.com/w/cpp/language/parameter_pack#Example