From 43a87590f45aa6e55724d30d0c2d0d34b407a57e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 17 Jan 2021 18:54:26 +0000 Subject: First cut modernizing and sanitizing --- ptr.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ptr.hpp (limited to 'ptr.hpp') diff --git a/ptr.hpp b/ptr.hpp new file mode 100644 index 0000000..b92b63e --- /dev/null +++ b/ptr.hpp @@ -0,0 +1,25 @@ +#ifndef PTR_H +#define PTR_H + +#include + +template class wrapped_ptr : public std::unique_ptr { +public: + using std::unique_ptr::unique_ptr; + wrapped_ptr() : std::unique_ptr {{}, {}} { } + + inline + operator Obj *() const + { + return this->get(); + } + + template + static auto + create(Obj * (*factory)(Args...), void (*deleter)(Obj *), Params &&... params) + { + return wrapped_ptr {factory(std::forward(params)...), deleter}; + } +}; + +#endif -- cgit v1.2.3