mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
Added one more example and some tests
This commit is contained in:
26
README.md
26
README.md
@@ -1,6 +1,6 @@
|
||||
# Precise and Flat Reflection (ex Magic Get, ex PODs Flat Reflection)
|
||||
|
||||
This C++14 library is meant for accessing structure elements by index and providing other std::tuple like methods for user defined types.
|
||||
This C++14 library is meant for accessing structure elements by index and providing other std::tuple like methods for user defined types without any macro or boilerplate code.
|
||||
|
||||
|
||||
[Latest documentation](http://apolukhin.github.com/magic_get/index.html)
|
||||
@@ -14,6 +14,30 @@ Branches | Build | Tests coverage | More info
|
||||
Develop: | [](https://travis-ci.org/apolukhin/magic_get) <!-- [](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/develop) --> | [](https://coveralls.io/github/apolukhin/magic_get?branch=develop) | <!-- [details...](http://www.boost.org/development/tests/develop/developer/pfr.html)) -->
|
||||
Master: | [](https://travis-ci.org/apolukhin/magic_get) <!-- [](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/master) --> | [](https://coveralls.io/github/apolukhin/magic_get?branch=master) | <!-- [details...](http://www.boost.org/development/tests/master/developer/pfr.html)) -->
|
||||
|
||||
### Motivating Example #0
|
||||
```c++
|
||||
// requires: C++14
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "boost/pfr.hpp"
|
||||
|
||||
struct some_person {
|
||||
std::string name;
|
||||
unsigned birth_year;
|
||||
};
|
||||
|
||||
int main() {
|
||||
some_person val{"Edgar Allan Poe", 1809};
|
||||
|
||||
std::cout << boost::pfr::get<0>(val)
|
||||
<< " was born in " << boost::pfr::get<1>(val);
|
||||
}
|
||||
```
|
||||
Outputs:
|
||||
```
|
||||
Edgar Allan Poe was born in 1809
|
||||
```
|
||||
|
||||
|
||||
### Motivating Example #1
|
||||
```c++
|
||||
|
||||
Reference in New Issue
Block a user