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