boost-ext / di

C++14 Dependency Injection Library
https://boost-ext.github.io/di
1.16k stars 140 forks source link

Extension constructor with extension shared not compiling #391

Open arude opened 5 years ago

arude commented 5 years ago

Expected Behavior

When I change the extension constructor binding example line , di::bind<variadic>().to(di::extension::constructor<int, std::string, std::unique_ptr<interface>>()) to , di::bind<variadic>().to(di::extension::constructor<int, std::string, std::unique_ptr<interface>>()).in(di::extension::shared) it should still compile. Added include #include <boost/di/extension/scopes/shared.hpp>

Actual Behavior

When I forward declare the variadic constructor type I get: boost/di.hpp(517): error C2139: 'nanosurf::nsfstd::core::core_hw_modules': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_final' (compiling source file workflow_manager_mobiles.cpp)

When I have the definition I get (this is as-is with the example mentioned: main.obj : error LNK2019: unresolved external symbol "public: static struct variadic __cdecl boost::di::v1_1_0::concepts::scoped<class boost::di::v1_1_0::extension::detail::shared,struct boost::di::v1_1_0::extension::constructor<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::unique_ptr<struct interface,struct std::default_delete<struct interface> > > >::is_not_convertible_to<struct variadic>::error(struct boost::di::v1_1_0::_)" (?error@?$is_not_convertible_to@Uvariadic@@@?$scoped@Vshared@detail@extension@v1_1_0@di@boost@@U?$constructor@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$unique_ptr@Uinterface@@U?$default_delete@Uinterface@@@std@@@2@@3456@@concepts@v1_1_0@di@boost@@SA?AUvariadic@@U_@456@@Z) referenced in function "public: __thiscall boost::di::v1_1_0::concepts::scoped<class boost::di::v1_1_0::extension::detail::shared,struct boost::di::v1_1_0::extension::constructor<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::unique_ptr<struct interface,struct std::default_delete<struct interface> > > >::is_not_convertible_to<struct variadic>::operator struct variadic(void)const " (??B?$is_not_convertible_to@Uvariadic@@@?$scoped@Vshared@detail@extension@v1_1_0@di@boost@@U?$constructor@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$unique_ptr@Uinterface@@U?$default_delete@Uinterface@@@std@@@2@@3456@@concepts@v1_1_0@di@boost@@QBE?AUvariadic@@XZ)

Specifications

Thank you for your help.

arude commented 5 years ago

Actually I tried now without the shared extension. If I add struct example final { example(variadic& var) {}; }; and injector.create<example>();

I get: di.hpp(2445): error C2440: 'return': cannot convert from 'wrapper_t' to 'create_t '

Shouldn't this work?