update readme
This commit is contained in:
parent
46ffb720ad
commit
2483b1f381
1 changed files with 25 additions and 18 deletions
43
README.md
43
README.md
|
@ -9,9 +9,11 @@
|
|||
|_| \_|\__,_|_| |_| |_|\___|\___/|_| \_____|
|
||||
```
|
||||
|
||||
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)
|
||||
[![License](https://img.shields.io/github/license/Neargye/nameof.svg)](LICENSE)
|
||||
[![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)
|
||||
[![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)
|
||||
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/irgD3NwQM2ikhVMC)
|
||||
|
||||
## What is Nameof?
|
||||
|
||||
|
@ -34,19 +36,20 @@ Header-only C++17 library provides nameof macros and functions to obtain simple
|
|||
|
||||
* Name of variable
|
||||
```cpp
|
||||
// Name of variable
|
||||
// Name of variable.
|
||||
NAMEOF(somevar) -> "somevar"
|
||||
// Name of member variable
|
||||
|
||||
// Name of member variable.
|
||||
NAMEOF(person.address.zip_code) -> "zip_code"
|
||||
```
|
||||
|
||||
* Name of function
|
||||
```cpp
|
||||
// Name of function
|
||||
// Name of function.
|
||||
NAMEOF(foo<int, float>()) -> "foo"
|
||||
NAMEOF_FULL(foo<int, float>()) -> "foo<int, float>"
|
||||
|
||||
// Name of member function
|
||||
// Name of member function.
|
||||
NAMEOF(somevar.some_method()) -> "some_method"
|
||||
NAMEOF_FULL(somevar.some_method<int>()) -> "some_method<int>"
|
||||
```
|
||||
|
@ -54,38 +57,42 @@ NAMEOF_FULL(somevar.some_method<int>()) -> "some_method<int>"
|
|||
* Name of enum
|
||||
```cpp
|
||||
auto color = Color::RED;
|
||||
// Name of enum variable
|
||||
// Name of enum variable.
|
||||
NAMEOF_ENUM(color) -> "RED"
|
||||
// Name of enum variable
|
||||
nameof::nameof_enum(color) -> "RED"
|
||||
|
||||
constexpr auto cx_color = Color::BLUE;
|
||||
// Name of static storage enum variable
|
||||
nameof::nameof_enum<cx_color>() -> "BLUE"
|
||||
constexpr auto const_color = Color::BLUE;
|
||||
// Name of static storage enum variable.
|
||||
NAMEOF_CONST_ENUM(const_color) -> "BLUE"
|
||||
nameof::nameof_enum<const_color>() -> "BLUE"
|
||||
```
|
||||
|
||||
* Name of type
|
||||
```cpp
|
||||
using T = int;
|
||||
T var = 42;
|
||||
// Name of variable type
|
||||
NAMEOF_TYPE(var) -> "int"
|
||||
// Name of variable type.
|
||||
NAMEOF_VAR_TYPE(var) -> "int"
|
||||
nameof::nameof_type<decltype(var)>() -> "int"
|
||||
// Name of type
|
||||
NAMEOF_TYPE_T(T) -> "int"
|
||||
|
||||
// Name of type.
|
||||
NAMEOF_TYPE(T) -> "int"
|
||||
nameof::nameof_type<T>() -> "int"
|
||||
```
|
||||
|
||||
* Name of macro
|
||||
```cpp
|
||||
// Name of macro
|
||||
// Name of macro.
|
||||
NAMEOF(__LINE__) -> "__LINE__"
|
||||
NAMEOF(NAMEOF(structvar)) -> "NAMEOF"
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
* Nameof return std::string_view.
|
||||
|
||||
* If arguments does not have name, Nameof return empty string.
|
||||
|
||||
* Nameof expression arguments are identified, but do not evaluated.
|
||||
|
||||
* NAMEOF_ENUM supported on the GCC >= 9.
|
||||
|
@ -94,7 +101,7 @@ NAMEOF(__LINE__) -> "__LINE__"
|
|||
```cpp
|
||||
NAMEOF_RAW(somevar.somefield) -> "somevar.somefield"
|
||||
NAMEOF_RAW(&SomeStruct::SomeMethod) -> "&SomeStruct::SomeMethod"
|
||||
NAMEOF_RAW(std::string) -> "std::string"
|
||||
NAMEOF_RAW(const SomeClass<int> volatile *) -> "const SomeClass<int> volatile *"
|
||||
```
|
||||
|
||||
* Spaces and Tabs ignored
|
||||
|
|
Loading…
Reference in a new issue