Another silly (and compiler specific) hack: use clang's __builtin_dump_struct and instead of printf provide it a compatible function which parses the string output :)
Interesting. I thought it only supports 'printf' (so it can only dump definition to stdout, instead of being consumed by my function to compute something else), but I just checked the lastest documentation and seems like now it supports any printf-like function.
But if you want constexpr reflection (like the one in my example) __builtin_dump_struct is still not enough.
2 comments
[ 0.16 ms ] story [ 19.5 ms ] threadhttps://www.godbolt.org/z/MGE3PT5a4
But if you want constexpr reflection (like the one in my example) __builtin_dump_struct is still not enough.