From e731faa3812ffdfe39729c0eae4a52833fd31117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sun, 27 Nov 2016 16:22:43 +0100 Subject: [PATCH] removed comments & questions, this version is cz approved --- Function.hpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Function.hpp b/Function.hpp index 0c9fbee..b7ef72e 100644 --- a/Function.hpp +++ b/Function.hpp @@ -3,20 +3,18 @@ -template // here Fun will be a function signature +template class Function; -// TODO: kérdezős kommentek eltüntetése leadás után -template // specialization, so we can work +template class Function { private: - class callable_base // type-erasure magic for functors + class callable_base { public: virtual Ret call(Args...) const = 0; - virtual ~callable_base() {} - //virtual ~callable_base() = default; // melyik számít szebbnek? van bármi különbség? + virtual ~callable_base() = default; }; template @@ -34,11 +32,6 @@ private: }; std::unique_ptr _fun; - /* kérdés, hogy ezt lehet-e szebben, vagy ez így a state-of-the-art megoldás? - * lent majd látod, de úgy van megoldva, hogy overloadolva van az operator= - * std::nullptr_t-re. próbáltam varázsolni ilyen std::is_null_pointer-rel, - * meg hasonlókkal a callable::operator()-ben, meg a Function::operator()-ben, - * de nem akarta az igazat. */ bool _is_null = false; public: @@ -52,7 +45,7 @@ public: return *this; } - Function& operator=(std::nullptr_t) // exploiting that decltype(nullptr) is std::nullptr_t + Function& operator=(std::nullptr_t) { _is_null = true; return *this; } Ret operator()(Args... args) const