Dependency injection is a simple design pattern that decouples a component from its dependency.
While the pattern introduces a virtual dispatch (with its runtime cost), its simplicity and effect on testability are usually worth it.
Click to open in Compiler Explorer.
Leave a comment
simple, though powerful, useful and important
I've been looking for a way to do this at compile time using templates but haven't found a solution. Is such a thing possible?