
Great question. There are multiple ways of distinguishing them but IMHO strong types would be the most elegant/encouraged when used with DI. struct X { name_t name; }; struct Y { title_t title }; auto injector = di::make_injector( bind<name_t>.to("name"), bind<title_t>.to("title") ); Alternatively, named annotations can be used too - https://boost-ext.github.io/di/tutorial.html (search named or annotations) Or what it's called a context injection auto injector = di::make_injector( bind<std::string>.when<X>.to("name"), bind<std::string>.when<Y>.to("title") ); On Sat, Feb 20, 2021 at 9:44 AM Peter Dimov via Boost <boost@lists.boost.org> wrote:
Krzysztof Jusiak wrote:
documentation: https://boost-ext.github.io/di/
This brings up one pretty obvious question, what if I have two constructor parameters of the same type:
struct X { std::string name; };
struct Y { std::string title; };
struct Z { X x; Y y; };
How do I inject specific values for X::name and Y::title?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost