clean-up
This commit is contained in:
parent
0016e037b4
commit
425046ecb6
4 changed files with 6 additions and 10 deletions
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
C++ alternative to [nameof](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator in C#.
|
C++ alternative to [nameof](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator in C#.
|
||||||
|
|
||||||
Linux/OSX | Windows
|
Branch | 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)
|
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.
|
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.
|
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.
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
set(SRC
|
set(SRC example.cpp)
|
||||||
example.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/src/nameof.hpp)
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}_example ${SRC})
|
add_executable(${PROJECT_NAME}_example ${SRC})
|
|
@ -31,6 +31,7 @@ inline constexpr bool IsLexeme(const char s) {
|
||||||
return (s == '.' || s == '>' || s == ':' || s == '&' || s == '*' ||
|
return (s == '.' || s == '>' || s == ':' || s == '&' || s == '*' ||
|
||||||
s == '+' || s == '~' || s == '-' || s == '!');
|
s == '+' || s == '~' || s == '-' || s == '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
inline constexpr const char* Nameof(const char(&name)[N], const std::size_t length = N) {
|
inline constexpr const char* Nameof(const char(&name)[N], const std::size_t length = N) {
|
||||||
return length == 0 ? name : IsLexeme(name[length - 1])
|
return length == 0 ? name : IsLexeme(name[length - 1])
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
include_directories(3rdparty/Catch2)
|
include_directories(3rdparty/Catch2)
|
||||||
|
|
||||||
set(SRC
|
set(SRC test.cpp)
|
||||||
test.cpp
|
|
||||||
3rdparty/Catch2/catch.hpp
|
|
||||||
${CMAKE_SOURCE_DIR}/src/nameof.hpp)
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}_test ${SRC})
|
add_executable(${PROJECT_NAME}_test ${SRC})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue