This commit is contained in:
Bela Schaum 2023-03-06 13:02:46 +00:00 committed by GitHub
parent 84ce6d87fb
commit 9494cbd4aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -988,7 +988,13 @@ constexpr auto get_member_name() noexcept {
if constexpr (std::is_member_function_pointer_v<decltype(V)>) { if constexpr (std::is_member_function_pointer_v<decltype(V)>) {
return n<V>(); return n<V>();
} else { } else {
constexpr bool is_defined = sizeof(decltype(get_base_type(V))) != 0;
static_assert(is_defined, "Member name can use only if the struct is already fully defined. Please use NAMEOF macro, or separate definition and declaration.");
if constexpr (is_defined) {
return n<V, &(union_type_holder<decltype(get_base_type(V))>::value.f.*V)>(); return n<V, &(union_type_holder<decltype(get_base_type(V))>::value.f.*V)>();
} else {
return "";
}
} }
} }