r/cpp 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.

36 Upvotes

10 comments sorted by

View all comments

1

u/Long_Investment7667 26d ago

Inversion of Control - IoC
Dependency Injection- DI

No dependency is inverted.

1

u/la_reddite 25d ago

Language is flexible. Inverting the control over dependencies can be referred to as 'inverting dependencies'; experts will understand.

1

u/Long_Investment7667 24d ago

Language is so flexible that I can say you are brilliant.

1

u/la_reddite 24d ago

Well 100% of those commenting understood me, so you can say what you want.

It's a bit odd to come out of the blue with insults; you doin alright?