{"id":23904809,"url":"https://github.com/sergio-eld/pod_reflection","last_synced_at":"2025-04-11T02:40:53.613Z","repository":{"id":51191319,"uuid":"201466586","full_name":"sergio-eld/pod_reflection","owner":"sergio-eld","description":"Simple C++ one-header stl based library implementing reflection for POD data types","archived":false,"fork":false,"pushed_at":"2021-05-20T12:18:45.000Z","size":68,"stargazers_count":28,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T00:18:38.692Z","etag":null,"topics":["cpp11","cpp14","header-only","header-stl","pod-reflection","reflection-library","type-traits"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergio-eld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-09T12:50:10.000Z","updated_at":"2024-10-15T16:02:54.000Z","dependencies_parsed_at":"2022-09-06T17:11:21.627Z","dependency_job_id":null,"html_url":"https://github.com/sergio-eld/pod_reflection","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergio-eld%2Fpod_reflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergio-eld%2Fpod_reflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergio-eld%2Fpod_reflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergio-eld%2Fpod_reflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergio-eld","download_url":"https://codeload.github.com/sergio-eld/pod_reflection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248330999,"owners_count":21085815,"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":["cpp11","cpp14","header-only","header-stl","pod-reflection","reflection-library","type-traits"],"created_at":"2025-01-05T00:47:15.823Z","updated_at":"2025-04-11T02:40:53.589Z","avatar_url":"https://github.com/sergio-eld.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pod_reflection\nThis is a simple C++ one-header STL based library implementing reflection for POD data types.\n\n## Limitations:\nC++ itself does not provide adequate means for reflection, so this library's\nimplementation is based around various template metaprogramming tools and hacks.\nThough this code is written according to the standard, there are some C++ features\nthat make it impossible to use this library. Here is the list of known limitations:\n- **Structs with default values for elements:** in C++ 11 structure is not considered as a POD in case it has default initializations \nfor any of its elements. In C++ 14 a structure is allowed to have default values for elements\n  and to remain a POD.\n- **Structs with bitfields:** It is impossible to get an address of a bitfield member of class in C++.\nAccessing a first bitfield element of an addressable location is possible,\n  but is still considered UB. So it is restricted to use (no valid results will be provided)\n  `eld::get` and `eld::for_each` on PODS that contain bitfields.\n- **Structs with fixed size arrays**: it seems to be impossible to deduce that an element is \na fixed size array because arrays can only be initialized only with brace initialization. \n  Thus an attempt to deduce an element will yield a type of an array element.\n  **Structs with fixed size array elements are prohibited from usage with\n  `eld::get`, `eld::for_each`**\n\n\n\n## Public API:\nThe following public functions are implemented within the library:\n*include/pod_reflection/pod_reflection.h* - new header to be used.\n\n- `eld::pod_size\u003cPOD\u003e` - get size of a POD structure at compile time\n- `eld::pod_element_t\u003cI, POD, TupleFeed\u003e` - get a type of an Ith element of a POD\nstructure. Tuple with feed types `TupleFeed` is required to deduce the Ith element type.\n- `deduced\u0026 get\u003cI, TupleFeed\u003e(POD\u0026 pod)` - extract the Ith element of POD using `TupleFeed`. \nThis function requires testing for a particular compiler since it utilizes UB (`reinterpret_cast` from an offset).-\n- `int eld::for_each\u003cTupleFeed\u003e(POD\u0026 pod, Callable \u0026\u0026callable)` - one of the most useful\nfunctions in practice. For each element in POD object calls a callable object. The most obvious use case\n  as can be seen from example - is to log (print) the contents of a POD structure.\n  The most useful case which this library can be used - **automatic endian conversion** for each\n  of the POD's element.\n  \n\n### Example usage:\nSee *example/main.cpp*.\nIn your CMakeLists.txt declare: `target_link_libraries(YourTarget PRIVATE eld::pod_reflection)`\n\n\n### Contributing:\nThis library requires automated testing with CI integration. Any help is appreciated.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergio-eld%2Fpod_reflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergio-eld%2Fpod_reflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergio-eld%2Fpod_reflection/lists"}