From 3e2479e216bdcb149f33ad3b8928134544b4382f Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Fri, 5 May 2017 09:02:39 +0800 Subject: [PATCH] Add void timer function support. (without metaprogramming) --- MiniEngine.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MiniEngine.h b/MiniEngine.h index 6412c3b..eca3106 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -467,11 +467,21 @@ namespace MiniEngine { public: Timer(); - /// Uint32 func(Uint32,void*) ... + + /// void func(Uint32,...) + template + Timer(Uint32 interval,VoidCallable&& vcallable,Args&&... args) : Timer() + { + auto realCall=[&](Uint32 ims)->Uint32{vcallable(ims,args...);return interval;}; + auto pfunc=new std::function(realCall); + _real_timer_call(_global_timer_executor,interval,pfunc); + } + + /// Uint32 func(Uint32,...) template Timer(Callable&& callable,Uint32 interval,Args&&... args) : Timer() { - auto realCall=[&](Uint32 interval)->Uint32{return callable(interval,args...);}; + auto realCall=[&](Uint32 ims)->Uint32{return callable(ims,args...);}; auto pfunc=new std::function(realCall); _real_timer_call(_global_timer_executor,interval,pfunc); }