A header-only C++17 library providing macros and functions to obtain the names of variables, types, functions, macros, and enums at compile-time.
Nameof is a header-only C++17 library that provides compile-time reflection capabilities to obtain string names of C++ entities such as variables, types, functions, macros, and enums. It solves the problem of manually hardcoding identifier names in debugging, logging, or serialization code, reducing errors and improving maintainability.
C++ developers working on projects that require logging, debugging, serialization, or runtime type information without heavy reflection overhead, particularly those using C++17 or later.
Developers choose Nameof for its simplicity, zero runtime overhead, and ease of integration as a single-header library, offering a lightweight alternative to complex reflection systems while supporting modern C++ features.
Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Most operations, like NAMEOF and NAMEOF_ENUM, are evaluated at compile-time, ensuring no runtime cost, which is ideal for performance-sensitive logging and serialization.
Supports variables, member expressions, functions, macros, enums, and types with dedicated macros like NAMEOF_FULL for full names and NAMEOF_SHORT for simplified names.
Header-only library with seamless support for vcpkg, Conan, and AUR, simplifying dependency management in various build systems.
Provides enum-to-string conversion with NAMEOF_ENUM, support for enum flags via NAMEOF_ENUM_FLAG, and fallbacks for out-of-range values, reducing manual error-prone code.
Only extracts string names and does not support deeper reflection like accessing member values or invoking methods, which restricts its use in complex serialization or introspection tasks.
Heavy use of macros can lead to naming conflicts, obscure error messages, and challenges in debugging, contrasting with modern C++ constexpr approaches.
Functionality is compiler-specific; the reference documentation notes varying support across compilers, requiring additional validation for cross-platform projects.