From bdee6b43d64e065860d5da8ab14830f799ba0e8d Mon Sep 17 00:00:00 2001 From: terik23 Date: Sat, 31 Mar 2018 04:28:44 +0500 Subject: [PATCH] simplified function Nameof --- src/nameof.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nameof.hpp b/src/nameof.hpp index 16ce444..3ce1988 100644 --- a/src/nameof.hpp +++ b/src/nameof.hpp @@ -27,8 +27,8 @@ namespace nameof { -template -constexpr const char* Nameof(const char* name, const size_t length) { +template +constexpr const char* Nameof(const char(&name)[N], const size_t length = N) { return length == 0 ? name : (name[length - 1] == ' ' || name[length - 1] == '.' || name[length - 1] == '>' || name[length - 1] == ':' || @@ -45,11 +45,11 @@ constexpr const char* Nameof(const char* name, const size_t length) { #define NAMEOF_RAW(x) NAMEOF_RAW_(x) // Used to obtain the string name of a variable, function and etc. -#define NAMEOF(name) nameof::Nameof(NAMEOF_RAW(name), sizeof(NAMEOF_RAW(name)) / sizeof(char) - 1) +#define NAMEOF(name) nameof::Nameof(NAMEOF_RAW(name)) #define NAMEOF_FULL(name) nameof::Nameof(NAMEOF_RAW(name), 0) // Used to obtain the string name of a type. -#define NAMEOF_TYPE(type) nameof::Nameof(NAMEOF_RAW(type), sizeof(NAMEOF_RAW(type)) / sizeof(char) - 1) +#define NAMEOF_TYPE(type) nameof::Nameof(NAMEOF_RAW(type)) #define NAMEOF_TYPE_FULL(type) nameof::Nameof(NAMEOF_RAW(type), 0)