removed comments & questions, this version is cz approved

This commit is contained in:
Kjistóf 2016-11-27 16:22:43 +01:00
parent 81b4313d10
commit e731faa381
1 changed files with 5 additions and 12 deletions

View File

@ -3,20 +3,18 @@
template <typename Fun> // here Fun will be a function signature
template <typename Fun>
class Function;
// TODO: kérdezős kommentek eltüntetése leadás után
template <typename Ret, typename... Args> // specialization, so we can work
template <typename Ret, typename... Args>
class Function<Ret(Args...)>
{
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 <typename Fun>
@ -34,11 +32,6 @@ private:
};
std::unique_ptr<callable_base> _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