Closed subbota-a closed 4 years ago
It is a bit confusing but it actually doesn't user unique scope binding in this case. If you call it with injector.create<std::shared_ptr<server>>
it uses default shared scope.
You can try to forbid unbound instantiations and this code will fail as there is no bound shared scope.
I'm sorry but your answer isn't clear to me. So, how to get two different 'server' instances if I want shared_ptr?
You need either to bind it in shared
scope (an extension) or use shared_config
to override default behavior from singleton
to shared
.
Of course nothing stops you from doing both.
Here is an example
Hi, @kanstantsin-chernik !
I was a bug in my example! I wrote
di::injector<client>
instead of
di::injector<shared_ptr<server>>
I just wonder why does the injector create me a server though
Consider the following example.