MCPcopy Create free account
hub / github.com/boost-ext/di / main

Function main

example/example.cpp:135–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133};
134
135int main() {
136 auto runtime_value = false;
137
138 // clang-format off
139 auto module = [&] {
140 return di::make_injector(
141 di::bind<>().to(runtime_value)
142 );
143 };
144
145 auto injector = di::make_injector(
146 di::bind<interface>().to<implementation>()
147 , di::bind<>().to(42)
148 , module()
149 );
150 // clang-format on
151
152 /*<<create `example` - member function call>>*/
153 {
154 auto object = injector.create<example>();
155 assert(object.run());
156 }
157
158 /*<<create `example` - free function call>>*/
159 {
160 auto object = di::create<example>(injector);
161 assert(object.run());
162 }
163}
164//->

Callers 1

example.cppFile · 0.70

Calls 4

moduleFunction · 0.70
make_injectorFunction · 0.50
toMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected