
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
(), di::bind () ); } 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