This commit is contained in:
Neargye 2018-04-28 18:04:30 +05:00
parent e10c76141b
commit d7dd863bba
3 changed files with 7 additions and 13 deletions

View file

@ -1,4 +1,4 @@
// nameof c++ example
// nameof example
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
// Copyright (c) 2018 Daniil Goncharov <neargye@gmail.com>.

View file

@ -52,19 +52,13 @@ inline constexpr const char* Nameof(const char* name, const std::size_t length,
} // namespace nameof
#if defined(__GNUC__) || defined(__clang__)
// Used to obtain the string name of a variable, type, function, macros and etc.
#define NAMEOF(name) ::nameof::Nameof(#name, sizeof(#name) / sizeof(char) - 1, sizeof(void(*)(__typeof__(name))))
# define NAMEOF(name) ::nameof::Nameof(#name, sizeof(#name) / sizeof(char) - 1, sizeof(void(*)(__typeof__(name))))
// Used to obtain the string full name of a variable, type, function, macros and etc.
#define NAMEOF_FULL(name) ::nameof::Nameof(#name, 0, sizeof(void(*)(__typeof__(name))))
#else
# define NAMEOF_FULL(name) ::nameof::Nameof(#name, 0, sizeof(void(*)(__typeof__(name))))
#elif defined(_MSC_VER)
// Used to obtain the string name of a variable, type, function, macros and etc.
#define NAMEOF(name) ::nameof::Nameof(#name, sizeof(#name) / sizeof(char) - 1, sizeof(typeid(name)))
# define NAMEOF(name) ::nameof::Nameof(#name, sizeof(#name) / sizeof(char) - 1, sizeof(typeid(name)))
// Used to obtain the string full name of a variable, type, function, macros and etc.
#define NAMEOF_FULL(name) ::nameof::Nameof(#name, 0, sizeof(typeid(name)))
# define NAMEOF_FULL(name) ::nameof::Nameof(#name, 0, sizeof(typeid(name)))
#endif

View file

@ -1,4 +1,4 @@
// nameof c++ test
// nameof test
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
// Copyright (c) 2018 Daniil Goncharov <neargye@gmail.com>.