Magic_Game/core/Common/Function.cpp

28 lines
362 B
C++
Raw Normal View History

2018-04-22 15:52:46 +08:00
#include "..\e2dcommon.h"
e2d::Function::Function()
2018-05-08 17:40:36 +08:00
: _func(nullptr)
2018-04-22 15:52:46 +08:00
{}
e2d::Function::Function(std::nullptr_t)
2018-05-08 17:40:36 +08:00
: _func(nullptr)
2018-04-22 15:52:46 +08:00
{
}
e2d::Function::Function(std::function<void()> func)
2018-05-08 17:40:36 +08:00
: _func(func)
2018-04-22 15:52:46 +08:00
{
}
void e2d::Function::operator()(void) const
{
2018-05-08 17:40:36 +08:00
if (_func)
2018-04-22 15:52:46 +08:00
{
2018-05-08 17:40:36 +08:00
_func();
2018-04-22 15:52:46 +08:00
}
}
e2d::Function::operator bool() const
{
2018-05-08 17:40:36 +08:00
return static_cast<bool>(_func);
2018-04-22 15:52:46 +08:00
}