From 0b9cbf7dd2c38b25c896e8028269cb866a1d37cb Mon Sep 17 00:00:00 2001 From: schaumb Date: Fri, 23 Jun 2023 10:58:40 +0200 Subject: [PATCH] remove union type, simplify --- include/nameof.hpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 2991602..e6db437 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -986,16 +986,7 @@ template From get_base_type(Type From::*); template -union union_type { - constexpr ~union_type() {} - char c = {}; - T f; -}; - -template -struct union_type_holder { - constexpr static union_type value; -}; +extern T nonexist_object; template constexpr auto get_member_name() noexcept { @@ -1005,7 +996,7 @@ constexpr 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::value.f.*V)>(); + return n(); } else { return ""; }