Limitations
July 23, 2026 ยท View on GitHub
Nameof
- If the argument does not have a name, the compilation error
"Expression does not have a name."occurs.
Nameof Type
-
This library uses a compiler-specific hack (based on
__PRETTY_FUNCTION__/__FUNCSIG__). -
nameof_type and nameof_type_rtti return a compiler-specific type name.
-
To check if nameof_type is supported by your compiler use the macro
NAMEOF_TYPE_SUPPORTEDor constexpr constantnameof::is_nameof_type_supported.
If nameof_type is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macroNAMEOF_TYPE_NO_CHECK_SUPPORT. -
To check if nameof_type_rtti is supported by your compiler use macro
NAMEOF_TYPE_RTTI_SUPPORTEDor constexpr constantnameof::is_nameof_type_rtti_supported.
If nameof_type_rtti is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macroNAMEOF_TYPE_NO_CHECK_SUPPORT. -
To check is nameof_member supported compiler use macro
NAMEOF_MEMBER_SUPPORTEDor constexpr constantnameof::is_nameof_member_supported.
If nameof_member used on unsupported compiler, occurs the compilation error. To suppress error define macroNAMEOF_TYPE_NO_CHECK_SUPPORT. -
To check is nameof_pointer supported compiler use macro
NAMEOF_POINTER_SUPPORTEDor constexpr constantnameof::is_nameof_pointer_supported.
If nameof_pointer used on unsupported compiler, occurs the compilation error. To suppress error define macroNAMEOF_TYPE_NO_CHECK_SUPPORT.
Nameof Enum
-
This library uses a compiler-specific hack (based on
__PRETTY_FUNCTION__/__FUNCSIG__), which works on Clang >= 5, MSVC >= 15.3 and GCC >= 9. -
To check if nameof_enum is supported by your compiler use the macro
NAMEOF_ENUM_SUPPORTEDor constexpr constantnameof::is_nameof_enum_supported.
If nameof_enum is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macroNAMEOF_ENUM_NO_CHECK_SUPPORT. -
Runtime reflection of ordinary enum values is limited to
[NAMEOF_ENUM_RANGE_MIN, NAMEOF_ENUM_RANGE_MAX].NAMEOF_ENUM_CONST,nameof::nameof_enum<V>(),NAMEOF_ENUM_FLAG, andnameof::nameof_enum_flag()are not restricted by this range.-
By default
NAMEOF_ENUM_RANGE_MIN = -128,NAMEOF_ENUM_RANGE_MAX = 127. -
NAMEOF_ENUM_RANGE_MINmust be less than or equal to0and must be greater thanINT16_MIN. -
NAMEOF_ENUM_RANGE_MAXmust be greater than0and must be less thanINT16_MAX. -
If another range is needed for all enum types by default, redefine the macro
NAMEOF_ENUM_RANGE_MINandNAMEOF_ENUM_RANGE_MAX.#define NAMEOF_ENUM_RANGE_MIN 0 #define NAMEOF_ENUM_RANGE_MAX 256 #include <nameof.hpp> -
If another range is needed for a specific enum type, add specialization
enum_rangefor necessary enum type. Specialization ofenum_rangemust be injected innamespace nameof::customize.#include <nameof.hpp> enum class number { one = 100, two = 200, three = 300 }; template <> struct nameof::customize::enum_range<number> { static constexpr int min = 100; static constexpr int max = 300; };
-
-
Names of aliased enum values are compiler-dependent.
-
Forward-declared enums are not supported.
-
Visual Studio IntelliSense may have problems analyzing some
nameofexpressions.