This commit is contained in:
Neargye 2018-05-29 20:51:18 +05:00
parent 744c8c8f43
commit b5eeb684b7
2 changed files with 2 additions and 4 deletions

View file

@ -13,8 +13,6 @@ Branch | Linux/OSX | Windows | License | Codacy
-------|-----------|---------|---------|------- -------|-----------|---------|---------|-------
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)|[![License](https://img.shields.io/github/license/Neargye/nameof.svg)](LICENSE)|[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1d06f3f07afe4f34acd29c0c8efa830b)](https://www.codacy.com/app/Neargye/nameof?utm_source=github.com&utm_medium=referral&utm_content=Neargye/nameof&utm_campaign=Badge_Grade) 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)|[![License](https://img.shields.io/github/license/Neargye/nameof.svg)](LICENSE)|[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1d06f3f07afe4f34acd29c0c8efa830b)](https://www.codacy.com/app/Neargye/nameof?utm_source=github.com&utm_medium=referral&utm_content=Neargye/nameof&utm_campaign=Badge_Grade)
C++ alternative to [nameof](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator in [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)).
Used to obtain the simple name of a variable, type, member, function, macros. Used to obtain the simple name of a variable, type, member, function, macros.
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.

View file

@ -5,7 +5,7 @@
// | |\ | (_| | | | | | | __/ (_) | | | |____|_| |_| // | |\ | (_| | | | | | | __/ (_) | | | |____|_| |_|
// |_| \_|\__,_|_| |_| |_|\___|\___/|_| \_____| // |_| \_|\__,_|_| |_| |_|\___|\___/|_| \_____|
// https://github.com/Neargye/nameof // https://github.com/Neargye/nameof
// vesion 0.2.5 // vesion 0.3.0
// //
// Licensed under the MIT License <http://opensource.org/licenses/MIT>. // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
// Copyright (c) 2016, 2018 Daniil Goncharov <neargye@gmail.com>. // Copyright (c) 2016, 2018 Daniil Goncharov <neargye@gmail.com>.
@ -43,7 +43,7 @@ inline constexpr bool IsLexeme(const char s) noexcept {
} // namespace detail } // namespace detail
inline constexpr const char* Nameof(const char* name, const ::std::size_t length) noexcept { inline constexpr const char* Nameof(const char* name, const std::size_t length) noexcept {
return ((length == 0) ? name : (detail::IsLexeme(name[length - 1]) return ((length == 0) ? name : (detail::IsLexeme(name[length - 1])
? &name[length] ? &name[length]
: Nameof(name, length - 1))); : Nameof(name, length - 1)));