r/cpp • • Sep 15 '26

From Templates to Reflection, Part 1: Back to the Basics with type_vector

https://daniel-petrovic.github.io/blog/type-vector-operating-on-types/
39 Upvotes

4 comments sorted by

7

u/NewLlama Sep 15 '26

I use this technique a lot in my code. It's really powerful but ADL tries to instantiate nested classes on unqualified calls when the type holder is an argument. So if you try to implement something like `operator+` you run into problems with forward-declared or otherwise uninstantiable types. There's a workaround but it's messy.

3

u/petrdan Sep 15 '26

Good point. I’d keep this API on explicit metafunctions rather than operator syntax for that reason.

4

u/zerhud Sep 15 '26

Why don’t use plain functions (as the boost.hana) instead of struct with templates?

2

u/petrdan Sep 16 '26

this will be the topic in the one of the next posts when we get to the reflection