diff --git a/README.md b/README.md index 4f94c01..fedb626 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ C++ alternative to [nameof](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator in C#. - Linux/OSX | Windows ------------|--------- -[![Build Status](https://travis-ci.org/Neargye/nameof.svg?branch=master)](https://travis-ci.org/Neargye/nameof)|[![Build status](https://ci.appveyor.com/api/projects/status/yq5fk0d9mwljbubt/branch/master?svg=true)](https://ci.appveyor.com/project/Neargye/nameof/branch/master) +Branch | Linux/OSX | Windows +-------|-----------|--------- +master |[![Build Status](https://travis-ci.org/Neargye/nameof.svg?branch=master)](https://travis-ci.org/Neargye/nameof)|[![Build status](https://ci.appveyor.com/api/projects/status/yq5fk0d9mwljbubt/branch/master?svg=true)](https://ci.appveyor.com/project/Neargye/nameof/branch/master) Used to obtain the simple name of a variable, type, member or function and etc. Before, you had to use string literals to refer to definitions, which is brittle when renaming code elements because tools do not know to check these string literals. diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 3b8eed8..e4643ff 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,7 +1,5 @@ include_directories(${CMAKE_SOURCE_DIR}/src) -set(SRC - example.cpp - ${CMAKE_SOURCE_DIR}/src/nameof.hpp) +set(SRC example.cpp) add_executable(${PROJECT_NAME}_example ${SRC}) \ No newline at end of file diff --git a/src/nameof.hpp b/src/nameof.hpp index ddeb1ba..1846361 100644 --- a/src/nameof.hpp +++ b/src/nameof.hpp @@ -31,6 +31,7 @@ inline constexpr bool IsLexeme(const char s) { return (s == '.' || s == '>' || s == ':' || s == '&' || s == '*' || s == '+' || s == '~' || s == '-' || s == '!'); } + template inline constexpr const char* Nameof(const char(&name)[N], const std::size_t length = N) { return length == 0 ? name : IsLexeme(name[length - 1]) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c02faf5..78dc856 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,7 @@ include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(3rdparty/Catch2) -set(SRC - test.cpp - 3rdparty/Catch2/catch.hpp - ${CMAKE_SOURCE_DIR}/src/nameof.hpp) +set(SRC test.cpp) add_executable(${PROJECT_NAME}_test ${SRC})