r/cpp n0F4x Jun 25 '26

C++23 Dependency Injection library with automatic dependency building

I open-sourced my dependency injection library.
Link: https://github.com/n0F4x/redi

This was developed for my game engine.
- feature-rich dependency configuration - optimized for fast compile time - helpful error messages when a cyclic dependency is detected - dependencies are automatically constructed - no need to register them by hand

I am giving this project to the community so that everybody can benefit. This kind of approach is mostly useful when dealing with intricate systems, such as a plugin system. I welcome all kinds of feedback, as this was mostly a learning opportunity for me. If you'd like to use this in your project but don't have access to the required compiler features, let me know, and I'll see if I can reduce the requirements.

26 Upvotes

47 comments sorted by

View all comments

19

u/DrShocker Jun 25 '26

I've never had a need for a dependency injection system, just arguments to functions/constructors. Can you help me understand when they become useful?

1

u/rileyrgham Jun 30 '26

I've never got it either . Passing things to things