added implementation for operator=
This commit is contained in:
parent
fe574be197
commit
f0e8e4f6ea
18
Function.hpp
18
Function.hpp
@ -16,11 +16,23 @@ private:
|
|||||||
class callable : public callable_base
|
class callable : public callable_base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Fun _f;
|
Fun _fun;
|
||||||
public:
|
public:
|
||||||
callable(Fun f):_f(f) {}
|
callable(Fun fun):_fun(fun) {}
|
||||||
virtual Ret call(Args... args)
|
virtual Ret call(Args... args)
|
||||||
{ return _f(std::forward<Args>(args)...); }
|
{ return _fun(std::forward<Args>(args)...); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
callable_base* _fun;
|
||||||
public:
|
public:
|
||||||
|
Function() {}
|
||||||
|
|
||||||
|
template <typename Fun>
|
||||||
|
Function& operator=(Fun fun)
|
||||||
|
{
|
||||||
|
_fun = new callable<Fun>(fun);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Function() { delete _fun; }
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user