Wrap with store

This commit is contained in:
schaumb 2023-06-23 11:20:00 +02:00
parent e662d0031e
commit 29a2938193

View file

@ -988,6 +988,14 @@ From get_base_type(Type From::*);
template <typename T>
extern T nonexist_object;
template<class T>
struct Store {
T v;
};
template<class T>
Store(T) -> Store<T>;
template <auto V>
consteval auto get_member_name() noexcept {
if constexpr (std::is_member_function_pointer_v<decltype(V)>) {
@ -996,7 +1004,7 @@ consteval auto get_member_name() noexcept {
constexpr bool is_defined = sizeof(decltype(get_base_type(V))) != 0;
static_assert(is_defined, "nameof::nameof_member 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, &(nonexist_object<decltype(get_base_type(V))>.*V)>();
return n<V, Store{&(nonexist_object<decltype(get_base_type(V))>.*V)}>();
} else {
return "";
}