Magic_Game/core/Common/Function.cpp

28 lines
359 B
C++
Raw Normal View History

2018-09-05 13:33:39 +08:00
#include "..\e2dutil.h"
2018-04-22 15:52:46 +08:00
e2d::Function::Function()
2018-09-04 22:42:34 +08:00
: func_(nullptr)
2018-04-22 15:52:46 +08:00
{}
e2d::Function::Function(std::nullptr_t)
2018-09-04 22:42:34 +08:00
: func_(nullptr)
2018-04-22 15:52:46 +08:00
{
}
e2d::Function::Function(std::function<void()> func)
2018-09-04 22:42:34 +08:00
: func_(func)
2018-04-22 15:52:46 +08:00
{
}
void e2d::Function::operator()(void) const
{
2018-09-04 22:42:34 +08:00
if (func_)
2018-04-22 15:52:46 +08:00
{
2018-09-04 22:42:34 +08:00
func_();
2018-04-22 15:52:46 +08:00
}
}
e2d::Function::operator bool() const
{
2018-09-04 22:42:34 +08:00
return static_cast<bool>(func_);
2018-04-22 15:52:46 +08:00
}