From 1ae511542c0b95314585fc98c08010318d50eadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sun, 27 Nov 2016 14:12:06 +0100 Subject: [PATCH] added missing virtual dtor for callable_base. first working version --- Function.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Function.hpp b/Function.hpp index f062472..4327e44 100644 --- a/Function.hpp +++ b/Function.hpp @@ -10,6 +10,8 @@ private: { public: virtual Ret call(Args...) = 0; + virtual ~callable_base() {} + //virtual ~callable_base() = default; // melyik számít szebbnek? van bármi különbség? }; template @@ -19,8 +21,11 @@ private: Fun _fun; public: callable(Fun fun):_fun(fun) {} - virtual Ret call(Args... args) + + virtual Ret call(Args... args) override { return _fun(std::forward(args)...); } + + virtual ~callable() override {} }; callable_base* _fun; @@ -37,5 +42,8 @@ public: Ret operator()(Args... args) const { return _fun->call(std::forward(args)...); } + operator bool() const + { return static_cast(_fun); } + ~Function() { delete _fun; } }; \ No newline at end of file