Closed eliemichel closed 4 years ago
Hello,
Yes, there is.
for_each(refl::reflect(x).members, [&](auto member) {
using member_type = decltype(member)::type;
if constexpr (std::is_same_v<member_type, bool>) {
std::cout << "bool" << member.name << " = " << (member(x) ? "true" : "false") << ";";
}
});
You were pretty close to the solution. type
is a typedef
on decltype(member)
. Please, note that this is the cv-qualified type of the member.
Great, thanks!
(edit: I believe it is ::value_type
rather than ::type
)
Is there a way to do something like this pseudo-code? I tried to read doc and code, but did not find.