![]() |
1 year ago | |
---|---|---|
.. | ||
include | 6128c83f47 Add yt into autobuild | 1 year ago |
CMakeLists.darwin-arm64.txt | ffff7a34e4 add darwin-arm64 CMakeLists | 1 year ago |
CMakeLists.darwin-x86_64.txt | 623315504d Move worker_node/service_node dependencies to ydb/library/yql | 1 year ago |
CMakeLists.linux-aarch64.txt | c76aaf823d Fix input variable missprint | 1 year ago |
CMakeLists.linux-x86_64.txt | c76aaf823d Fix input variable missprint | 1 year ago |
CMakeLists.txt | 96458ea3c7 External build system generator release 65 | 1 year ago |
LICENSE_1_0.txt | 6128c83f47 Add yt into autobuild | 1 year ago |
README.md | 6128c83f47 Add yt into autobuild | 1 year ago |
ya.make | 6128c83f47 Add yt into autobuild | 1 year ago |
This is a C++14 library for very basic reflection that gives you access to structure elements by index and provides other std::tuple
like methods for user defined types without any macro or boilerplate code.
Boost.PFR is a part of the Boost C++ Libraries. However, Boost.PFR is a header only library that does not depend on Boost. You can just copy the content of the "include" folder from the github into your project, and the library will work fine.
For a version of the library without boost::
namespace see PFR.
Branches | Build | Tests coverage | More info |
---|---|---|---|
Develop: | ![]() |
details... | |
Master: | ![]() |
details... |
Latest developer documentation
#include <iostream>
#include <fstream>
#include <string>
#include "pfr.hpp"
struct some_person {
std::string name;
unsigned birth_year;
};
int main(int argc, const char* argv[]) {
some_person val{"Edgar Allan Poe", 1809};
std::cout << pfr::get<0>(val) // No macro!
<< " was born in " << pfr::get<1>(val); // Works with any aggregate initializables!
if (argc > 1) {
std::ofstream ofs(argv[1]);
ofs << pfr::io(val); // File now contains: {"Edgar Allan Poe", 1809}
}
}
Outputs:
Edgar Allan Poe was born in 1809
#include <iostream>
#include "pfr/precise.hpp"
struct my_struct { // no ostream operator defined!
int i;
char c;
double d;
};
int main() {
my_struct s{100, 'H', 3.141593};
std::cout << "my_struct has " << pfr::tuple_size<my_struct>::value
<< " fields: " << pfr::io(s) << "\n";
}
Outputs:
my_struct has 3 fields: {100, H, 3.14159}
#include <iostream>
#include "pfr/precise.hpp"
struct my_struct { // no ostream operator defined!
std::string s;
int i;
};
int main() {
my_struct s{{"Das ist fantastisch!"}, 100};
std::cout << "my_struct has " << pfr::tuple_size<my_struct>::value
<< " fields: " << pfr::io(s) << "\n";
}
Outputs:
my_struct has 2 fields: {"Das ist fantastisch!", 100}
Distributed under the Boost Software License, Version 1.0.