From 6c1aa3c09b88d07f8bedaf58a495b4d521dbd056 Mon Sep 17 00:00:00 2001 From: terik23 Date: Mon, 8 Apr 2019 23:02:53 +0500 Subject: [PATCH] update readme --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7885077..48b0fbb 100644 --- a/README.md +++ b/README.md @@ -60,11 +60,6 @@ Header-only C++17 library provides nameof macros and functions to obtain simple // Name of enum variable. NAMEOF_ENUM(color) -> "RED" nameof::nameof_enum(color) -> "RED" - - constexpr auto const_color = Color::BLUE; - // Name of static storage enum variable. - NAMEOF_CONST_ENUM(const_color) -> "BLUE" - nameof::nameof_enum() -> "BLUE" ``` * Nameof type @@ -80,6 +75,18 @@ Header-only C++17 library provides nameof macros and functions to obtain simple nameof::nameof_type() -> "int" ``` +* Compile-time + ```cpp + constexpr auto somevar_name = NAMEOF(somevar); + // somevar_name -> "somevar" + constexpr auto color_name = NAMEOF_ENUM(Color::BLUE); // or nameof::nameof_enum(Color::BLUE) + // color_name -> "BLUE" + constexpr auto var_type_name = NAMEOF_VAR_TYPE(var); // or nameof::nameof_type() + // var_type_name -> "int" + constexpr auto type_name = NAMEOF_VAR_TYPE(T); // or nameof::nameof_type() + // type_name -> "int" + ``` + ## Remarks * Nameof returns `std::string_view`. If argument does not have name, returns empty string.