r/cpp • u/la_reddite • Aug 12 '26
Another C++26 reflection based dependency inverter
Someone else did a similar thing a few months ago, but I wanted to see if it could be done with templates.
I ended up writing a dependency inverter/injector that can reflect on the concepts restricting unfilled template types and substitute actual types into them. Unfortunately, C++26 reflection doesn't seem to allow reflection of concepts like this, so I did it with string parsing.
The result is... fairly janky, but you can play around with it here.
37
Upvotes
View all comments
Show parent comment
3
u/gracicot Aug 12 '26
At the time I started development of my library, boost DI was not a thing yet. In the end my lib got somewhat popular for a DI library. Why don't you give it a try over boost DI? :P
I'm still developing it because I'm no longer "young and naive" me, I'm now "old and naive" me, and I want to make it better and C++20 based.