From 9b91f5498661a34b4d1b81659c1ee26d07810816 Mon Sep 17 00:00:00 2001 From: terik23 Date: Sat, 17 Mar 2018 10:04:43 +0500 Subject: [PATCH] Fix workaround NAMEOF_FUNCTION --- src/nameof.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nameof.hpp b/src/nameof.hpp index 69a3df6..5bc7c6c 100644 --- a/src/nameof.hpp +++ b/src/nameof.hpp @@ -38,9 +38,11 @@ inline constexpr const char* template_nameof_variable(const T& validate_type, co // Used to obtain the string name of a type. #define NAMEOF_TYPE(type) template_nameof_type(#type) -template inline constexpr const char* template_nameof_type(const char* name) { return name; } +template +inline constexpr const char* template_nameof_type(const char* name) { return name; } // Used to obtain the string name of a function. -#define NAMEOF_FUNCTION(function) template_nameof_function(#function, sizeof(#function) / sizeof(char) - 1); if (false) (void)(function); +#define NAMEOF_FUNCTION(function) template_nameof_function(#function, sizeof(#function) / sizeof(char) - 1) +template inline constexpr const char* template_nameof_function(const char* name, size_t length) { return template_nameof_(name, length); } #define NAMEOF_FUN(fun) NAMEOF_FUNCTION(fun)