From 087f3d45bd28f714cd0629206e7bb4de0b91e6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sun, 27 Nov 2016 14:15:10 +0100 Subject: [PATCH] swapped old-school new -> delete to fancy std::unique_ptr --- Function.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Function.hpp b/Function.hpp index 4327e44..47209ea 100644 --- a/Function.hpp +++ b/Function.hpp @@ -1,3 +1,7 @@ +#include + + + template class Function; @@ -28,14 +32,15 @@ private: virtual ~callable() override {} }; - callable_base* _fun; + std::unique_ptr _fun; + public: Function() {} template Function& operator=(Fun fun) { - _fun = new callable(fun); + _fun = std::make_unique>(fun); return *this; } @@ -44,6 +49,4 @@ public: operator bool() const { return static_cast(_fun); } - - ~Function() { delete _fun; } }; \ No newline at end of file