{"id":13533629,"url":"https://github.com/boostorg/pfr","last_synced_at":"2025-05-14T13:08:08.157Z","repository":{"id":45466263,"uuid":"54502907","full_name":"boostorg/pfr","owner":"boostorg","description":"std::tuple like methods for user defined types without any macro or boilerplate code","archived":false,"fork":false,"pushed_at":"2025-05-12T12:53:19.000Z","size":1264,"stargazers_count":1387,"open_issues_count":52,"forks_count":160,"subscribers_count":47,"default_branch":"develop","last_synced_at":"2025-05-12T13:38:37.151Z","etag":null,"topics":["boost","clang","cplusplus","cplusplus-14","cpp","cpp14","cpp17","gcc","magic","reflection","reflection-library","reflections","std","tuple","tuples","visual-studio"],"latest_commit_sha":null,"homepage":"https://boost.org/libs/pfr","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boostorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-22T19:26:49.000Z","updated_at":"2025-05-09T22:25:28.000Z","dependencies_parsed_at":"2023-09-27T18:04:20.213Z","dependency_job_id":"faa5c7af-1abe-4353-b509-91c49c79ad18","html_url":"https://github.com/boostorg/pfr","commit_stats":{"total_commits":605,"total_committers":26,"mean_commits":23.26923076923077,"dds":0.2528925619834711,"last_synced_commit":"f09e6aeae9d050897fff72b93d5f5e866cc5e11a"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fpfr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fpfr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fpfr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fpfr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boostorg","download_url":"https://codeload.github.com/boostorg/pfr/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149960,"owners_count":22022851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boost","clang","cplusplus","cplusplus-14","cpp","cpp14","cpp17","gcc","magic","reflection","reflection-library","reflections","std","tuple","tuples","visual-studio"],"created_at":"2024-08-01T07:01:21.590Z","updated_at":"2025-05-14T13:08:03.116Z","avatar_url":"https://github.com/boostorg.png","language":"C++","readme":"# [Boost.PFR](https://boost.org/libs/pfr)\n\nThis 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.\n\n[Boost.PFR](https://boost.org/libs/pfr) is a part of the [Boost C++ Libraries](https://github.com/boostorg). 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.\n\nFor a version of the library without `boost::` namespace see [PFR](https://github.com/apolukhin/pfr_non_boost).\n\n### Test results\n\nBranches        | Build         | Tests coverage | More info\n----------------|-------------- | -------------- |-----------\nDevelop:        | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/0mavmnkdmltcdmqa/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/pfr/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=develop)](https://coveralls.io/github/apolukhin/magic_get?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/pfr.html)\nMaster:         | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/0mavmnkdmltcdmqa/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/pfr/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=master)](https://coveralls.io/github/apolukhin/magic_get?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/pfr.html)\n\n[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/boost_pfr.html)\n\n### Motivating Example #0\n```c++\n#include \u003ciostream\u003e\n#include \u003cfstream\u003e\n#include \u003cstring\u003e\n\n#include \"boost/pfr.hpp\"\n\nstruct some_person {\n  std::string name;\n  unsigned birth_year;\n};\n\nint main(int argc, const char* argv[]) {\n  some_person val{\"Edgar Allan Poe\", 1809};\n\n  std::cout \u003c\u003c boost::pfr::get\u003c0\u003e(val)                // No macro!\n      \u003c\u003c \" was born in \" \u003c\u003c boost::pfr::get\u003c1\u003e(val);  // Works with any aggregate initializables!\n\n  if (argc \u003e 1) {\n    std::ofstream ofs(argv[1]);\n    ofs \u003c\u003c boost::pfr::io(val);                       // File now contains: {\"Edgar Allan Poe\", 1809}\n  }\n}\n```\nOutputs:\n```\nEdgar Allan Poe was born in 1809\n```\n\n[Run the above sample](https://godbolt.org/z/PfYsWKb7v)\n\n\n### Motivating Example #1\n```c++\n#include \u003ciostream\u003e\n#include \"boost/pfr.hpp\"\n\nstruct my_struct { // no ostream operator defined!\n    int i;\n    char c;\n    double d;\n};\n\nint main() {\n    my_struct s{100, 'H', 3.141593};\n    std::cout \u003c\u003c \"my_struct has \" \u003c\u003c boost::pfr::tuple_size\u003cmy_struct\u003e::value\n        \u003c\u003c \" fields: \" \u003c\u003c boost::pfr::io(s) \u003c\u003c \"\\n\";\n}\n\n```\n\nOutputs:\n```\nmy_struct has 3 fields: {100, H, 3.14159}\n```\n\n### Motivating Example #2\n\n```c++\n#include \u003ciostream\u003e\n#include \"boost/pfr.hpp\"\n\nstruct my_struct { // no ostream operator defined!\n    std::string s;\n    int i;\n};\n\nint main() {\n    my_struct s{{\"Das ist fantastisch!\"}, 100};\n    std::cout \u003c\u003c \"my_struct has \" \u003c\u003c boost::pfr::tuple_size\u003cmy_struct\u003e::value\n        \u003c\u003c \" fields: \" \u003c\u003c boost::pfr::io(s) \u003c\u003c \"\\n\";\n}\n\n```\n\nOutputs:\n```\nmy_struct has 2 fields: {\"Das ist fantastisch!\", 100}\n```\n\n### Motivating Example #3\n\n```c++\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\n#include \u003cboost/config/warning_disable.hpp\u003e\n#include \u003cboost/spirit/home/x3.hpp\u003e\n#include \u003cboost/fusion/include/adapt_boost_pfr.hpp\u003e\n\n#include \"boost/pfr/io.hpp\"\n\nnamespace x3 = boost::spirit::x3;\n\nstruct ast_employee { // No BOOST_FUSION_ADAPT_STRUCT defined\n    int age;\n    std::string forename;\n    std::string surname;\n    double salary;\n};\n\nauto const quoted_string = x3::lexeme['\"' \u003e\u003e +(x3::ascii::char_ - '\"') \u003e\u003e '\"'];\n\nx3::rule\u003cclass employee, ast_employee\u003e const employee = \"employee\";\nauto const employee_def =\n    x3::lit(\"employee\")\n    \u003e\u003e '{'\n    \u003e\u003e  x3::int_ \u003e\u003e ','\n    \u003e\u003e  quoted_string \u003e\u003e ','\n    \u003e\u003e  quoted_string \u003e\u003e ','\n    \u003e\u003e  x3::double_\n    \u003e\u003e  '}'\n    ;\nBOOST_SPIRIT_DEFINE(employee);\n\nint main() {\n    std::string str = R\"(employee{34, \"Chip\", \"Douglas\", 2500.00})\";\n    ast_employee emp;\n    x3::phrase_parse(str.begin(),\n                     str.end(),\n                     employee,\n                     x3::ascii::space,\n                     emp);\n    std::cout \u003c\u003c boost::pfr::io(emp) \u003c\u003c std::endl;\n}\n\n```\nOutputs:\n```\n(34 Chip Douglas 2500)\n```\n\n\n### Requirements and Limitations\n\n[See docs](https://www.boost.org/doc/libs/develop/doc/html/boost_pfr.html).\n\n### License\n\nDistributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).\n","funding_links":[],"categories":["Libraries","C++"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostorg%2Fpfr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboostorg%2Fpfr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostorg%2Fpfr/lists"}