ARTICLE AD BOX
I've noticed that C++ reflection shipped with has_default_member_initializer, but no matching default_member_initializer_of. Is it possible to implement this using the tools provided with C++26's reflection?
For example, given the following:
struct test { int value = 42; };Is it possible to implement a default_member_initializer_of such that the following succeeds?
static_assert(has_default_member_initializer(^^test::value)); static_assert(default_member_initializer_of(^^test::value) == reflect_constant(42));Attempting to use something like constant_of fails, and I wasn't able to figure out a good way to "force" it by constructing an instance of test (from something like parent_of when receiving ^^test::value) and extracting the value from that.
I'm hoping that it is possible to implement while passing a std::meta::info as a parameter to the function, but would open to ways in which templates could be used as well.
1
Explore related questions
See similar questions with these tags.
