Somehow, Guice survives by detecting things at runtime so I would take from their experience that it is not a completely terrible proposition.
Yea, but they didn't really have the opportunity to do it as well, did they? In the end C++ compile time checking possibilities are more complex than Java ones. I'm not saying runtime checking it's terrible proposition, but IMHO compile time checking will always be a better option, just because errors might be spotted earlier.
Is it possible to automatically convert a static injector to a dynamic one? This might be the best of both worlds. That is, something like this:
di::injector<> SomeModule() { return di::make_injector( di::bind<ilogger,logger>(), di::bind<ilogic,logic>() ); }
I think you have all the information you need to do this. I'd encourage you to continue to develop the "dynamic" portion in a way that you're happy with it. Personally, I'd be happy if the above worked.
Yea, its possible to convert static injector to dynamic one. Presented proof-of-concept (https://github.com/krzysztof-jusiak/di_runtime_injector) was able to do so. There was one thing which couldn't be implemented in runtime tho - which was interface deduction. di::injector<> injector = di::make_injector( di::deduce<implementation>() // didn't work properly in runtime, use di::bind<interface, implementation>() instead ); But it's not as big deal I guess, although make both interfaces a bit different :/ Anyway I can implement runtime injector fairly easy. I'm just still not totally convinced it's really worth to do so, but definitely runtime injector might be an option to choose from in the end? Kris -- View this message in context: http://boost.2283326.n4.nabble.com/Is-there-any-interest-in-a-dependency-inj... Sent from the Boost - Dev mailing list archive at Nabble.com.