From 5ee05a7781396004cb617002b6cbe8b7402616a6 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Fri, 21 Jul 2017 12:32:13 +0300 Subject: [core] make actor self reference optional --- include/mbgl/actor/actor.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/mbgl/actor/actor.hpp b/include/mbgl/actor/actor.hpp index 00e1bb82f8..74d5a66285 100644 --- a/include/mbgl/actor/actor.hpp +++ b/include/mbgl/actor/actor.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace mbgl { @@ -47,10 +48,21 @@ namespace mbgl { template class Actor : public util::noncopyable { public: - template + + // Enabled for Objects with a constructor taking ActorRef as the first parameter + template , Args...>::value>::type...> + Actor(Scheduler& scheduler, Args&&... args_) + : mailbox(std::make_shared(scheduler)), + object(self(), std::forward(args_)...) { + } + + // Enabled for plain Objects + template , Args...>::value>::type...> Actor(Scheduler& scheduler, Args&&... args_) - : mailbox(std::make_shared(scheduler)), - object(self(), std::forward(args_)...) { + : mailbox(std::make_shared(scheduler)), + object(std::forward(args_)...) { } ~Actor() { -- cgit v1.2.1