boost-ext/di

Injector as class member

ValentinNikin opened this issue · 1 comments

I have the configured injector, for example like this

auto injector = boost::di::make_injector(
            boost::di::bind<AgentsController>().in(boost::di::unique),
            boost::di::bind<AgentCommunicatorController>().in(boost::di::unique),
            boost::di::bind<IAgentsManager>.to<WorkflowManager>().in(boost::di::singleton),
            boost::di::bind<IAgentCommunicator>.to<WorkflowManager>().in(boost::di::singleton)
            );

I want to write Types Factory with this injector, something like this. But the question is what type should injector member be?

class TypesFactory {
public:
    template<typename T>
    T resolve() {
        return _injector.create<T>();
    }
private:
SomeTypeOfInjector _injector; <---- What type should SomeTypeOfInjector be?
}

Specifications

  • Version: boost::di 1.2.0
  • Platform: debian 11

have the same issue. @ValentinNikin Do you figure out a solution?