boost-ext / di

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

no instance of function template "boost::di::v1_0_2::make_injector" matches the argument list #302

Closed nicholasc closed 6 years ago

nicholasc commented 6 years ago

Expected Behavior

Using the basic example from the readme, I would expect the following code to compile:

const auto injector = di::make_injector(
  di::bind<int>.to(42),
  di::bind<double>.to(87.0)
);

Actual Behavior

I get a compile error

no instance of function template "boost::di::v1_0_2::make_injector" matches the argument list
71                  argument types are: (dependency, dependency)

Steps to Reproduce the Problem

  1. Use the Quick guide - Create object graph example in the readme

Specifications

I know this is a long shot. Let me know if I need to provide additional information.

kris-jusiak commented 6 years ago

Thanks, @nicholasc.

I think MSVC still doesn't support DI variable template usage. Hence, you have to put () after bind.

di::bind<int>().to(42)
di::bind<double>().to(87.0)

Working example here -> https://godbolt.org/g/vBp3hD

Hopefully, that will help.

nicholasc commented 6 years ago

Well that was simple... Thanks @krzysztof-jusiak.

Should this be documented in the readme or somewhere else?

garyng commented 6 years ago

Same environment as OP, the code still compiles, but it still shows up as errors. Any ideas?

image