From e74576f6b0d5f4d33cdd4f7f236023e24974bcd5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 22 Mar 2018 04:19:33 +0100 Subject: [PATCH] DI: pass-through arbitrary arguments for initialisation of a ServiceInstance ...this part is a no-brainer. However, it is not clear yet if we can (and want to) do something similar for deferred (lazy) instance creation --- src/lib/depend-inject.hpp | 7 +++++-- wiki/thinkPad.ichthyo.mm | 43 +++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/lib/depend-inject.hpp b/src/lib/depend-inject.hpp index f93956fcf..b5bde307d 100644 --- a/src/lib/depend-inject.hpp +++ b/src/lib/depend-inject.hpp @@ -40,12 +40,14 @@ #include "lib/sync-classlock.hpp" #include +#include #include namespace lib { namespace error = lumiera::error; + using std::forward; using std::move; @@ -108,8 +110,9 @@ namespace lib { std::unique_ptr instance_; public: - ServiceInstance() - : instance_(new IMP{}) + template + ServiceInstance(ARGS&& ...ctorArgs) + : instance_(new IMP(forward (ctorArgs)...)) { __assert_compatible(); activateServiceAccess (*instance_); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7d952389c..46a956f7a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -26809,7 +26809,8 @@ - + + @@ -26839,7 +26840,26 @@ - + + + + + + + + +

+ sie werden ja sofort ausgewertet, da die Service-Instanz unmittelbar gebaut wird +

+ + +
+ +
+ + + +
@@ -27193,16 +27213,23 @@ - - + + - - + + - - + + + + + + + + +