When injecting shared_ptr<>s dependencies for an object, first inject (pointers to) all dependencies and then construct all the shared_ptr<>s at the end, before calling the constructor/provider. This helps the optimizer optimize out increments/decrements/checks of the shared_ptr<> reference count (this is useful at least for GCC 6; e.g. Clang 4 already optimized those out without this re-organization of the code).
3 files changed
tree: 824e6e09dc99f446da675d96d38a7471cb57f410
  1. configuration/
  2. examples/
  3. extras/
  4. include/
  5. src/
  6. tests/
  7. .gitignore
  8. .travis.yml
  9. appveyor.yml
  10. BUILD
  11. CMakeLists.txt
  12. CONTRIBUTING.md
  13. COPYING
  14. README.md
README.md

Build Status Build status Coverity Scan Status

Fruit is a dependency injection framework for C++, loosely inspired by the Guice framework for Java. It uses C++ metaprogramming together with some new C++11 features to detect most injection problems at compile-time. It allows to split the implementation code in "components" (aka modules) that can be assembled to form other components. From a component with no requirements it's then possible to create an injector, that provides an instance of the interfaces exposed by the component.

See the wiki for more information, including installation instructions, tutorials and reference documentation.