Closed jsoulier closed 2 years ago
Hey, I am looking to iterate through the fields of a struct and query their sizes without needing an object instance. I'm sure that there is method provided but I don't see it.
Currently, I have a working function similar to the following.
template <typename T> void func() { T t; T::Class::ForEachField(t, [&](auto &field, &auto value) { // sizeof(value) }); }
Is there anyway to do something like the following instead?
template <typename T> void func() { T::Class::ForEachField([&](auto &field) { // query type sizes e.g. sizeof(field.Type) }); }
Thanks
Sure can, example: https://godbolt.org/z/nvve6sxWd
Appreciate it, thanks.
Hey, I am looking to iterate through the fields of a struct and query their sizes without needing an object instance. I'm sure that there is method provided but I don't see it.
Currently, I have a working function similar to the following.
Is there anyway to do something like the following instead?
Thanks