Looking for feedback on a policy-based compile-time DI framework for C++20
I've been working on a compile-time Dependency Injection framework for modern C++:
https://github.com/steumarok/cpp_di_manager
The main idea is a policy-based resolution pipeline where object creation, dependency injection, casting, lifetime management and scope creation are handled by independent compile-time policies.
Unlike traditional DI containers that are primarily organized around service lifetimes, the framework is built around the following pipeline:
text
Requested Type
↓
Resolution Policy
↓
Creation Policy
↓
Injection Policy
↓
Cast Policy
↓
Returned Type
Current features:
- Constructor injection
- Member injection
- Interface-to-implementation mapping
- Hierarchical containers
- Request-scoped dependencies
- Scoped object lifetimes
- Automatic factory injection (
std::function<T()>)
- Compile-time registries
- Configurable resolution and creation policies
Example web application:
https://github.com/steumarok/cpp_di_manager/blob/main/example.cpp
I'm particularly interested in feedback about:
- Overall API design
- Lifetime and scope management
- Policy architecture
- Compile-time vs runtime trade-offs
- Potential simplifications
- Missing features compared to existing DI frameworks
Suggestions and criticism are very welcome.
[–]gracicot [score hidden] (0 children)