From 29a29381934c8f6ca89f328374085957eed90fd3 Mon Sep 17 00:00:00 2001 From: schaumb Date: Fri, 23 Jun 2023 11:20:00 +0200 Subject: [PATCH] Wrap with store --- include/nameof.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 1df8211..f1c32c4 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -988,6 +988,14 @@ From get_base_type(Type From::*); template extern T nonexist_object; +template +struct Store { + T v; +}; + +template +Store(T) -> Store; + template consteval auto get_member_name() noexcept { if constexpr (std::is_member_function_pointer_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)>(); + return n.*V)}>(); } else { return ""; }