From f0e8e4f6ea955b79dd6bac912899810abc516de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sun, 27 Nov 2016 14:06:57 +0100 Subject: [PATCH] added implementation for operator= --- Function.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Function.hpp b/Function.hpp index c670842..5232290 100644 --- a/Function.hpp +++ b/Function.hpp @@ -16,11 +16,23 @@ private: class callable : public callable_base { private: - Fun _f; + Fun _fun; public: - callable(Fun f):_f(f) {} + callable(Fun fun):_fun(fun) {} virtual Ret call(Args... args) - { return _f(std::forward(args)...); } + { return _fun(std::forward(args)...); } }; + + callable_base* _fun; public: + Function() {} + + template + Function& operator=(Fun fun) + { + _fun = new callable(fun); + return *this; + } + + ~Function() { delete _fun; } }; \ No newline at end of file