339 Commits

Author SHA1 Message Date
Fedor Osetrov 7d4343cb9a fix ci: turn on import std tests (#233)
This PR enables tests with `import std` usage in CI
2026-04-24 18:01:04 +03:00
Antony Polukhin eaa6c064b9 Fix build in C++14 mode (#232) 2026-02-06 20:58:12 +03:00
Antony Polukhin 8a66acc3cc C++26 reflection based implementation (#231) 2026-02-01 22:36:44 +03:00
Antony Polukhin adfce351d1 Allow stateful visitors in for_each_field*() (#230) 2026-01-26 20:38:17 +03:00
Antony Polukhin 228922fdb5 Update copyright years 2026-01-04 11:26:11 +03:00
Antony Polukhin 4f9e6457b0 Add multiple tests from different bug reports and make sure that ever… (#222)
…ything works with new unsafe_declval and with sturctured binding pack

Fixes: https://github.com/boostorg/pfr/issues/208,  https://github.com/boostorg/pfr/issues/110, https://github.com/boostorg/pfr/issues/126
Closes: https://github.com/boostorg/pfr/pull/212
Relates: https://github.com/boostorg/pfr/issues/173
2025-09-14 14:59:25 +03:00
Antony Polukhin fc2dba87d6 Multiple fixes for the structured bindings pack implementation (#221) 2025-09-11 21:51:07 +03:00
Antony Polukhin d9fde1f2a0 core: add an implementation based on C++26 destructuring into a pack (#220)
Tested with clang-21

---------

Co-authored-by: Jean-Michaël Celerier <jeanmichael.celerier@gmail.com>
2025-09-07 20:26:44 +03:00
Antony Polukhin 5034bf55fb Provide and use an alternative implementation of unsafe_declval (#216)
References https://github.com/boostorg/pfr/issues/208
2025-06-27 20:46:59 +03:00
Antony Polukhin dcf2deb959 Fix for 'Arrays of Length Zero' compiler extension (#213) 2025-06-20 15:56:51 +03:00
Antony Polukhin 820f56c316 Fix typos (#210)
Thanks to https://github.com/TryKuhn for highlighting the issues
2025-06-17 10:39:53 +03:00
Antony Polukhin db9451143a Fix build on standards before C++20 2025-05-12 19:53:03 +03:00
Antony Polukhin f004e91c9b Return std::array<std::string_view, 0> type for boost::pfr::names_as_array(empty_struct{}) (fixes #195) 2025-05-12 19:53:03 +03:00
Antony Polukhin 5a48d7456f Rewrite modules following the new recommended Boost practice (#196)
Changes:

1) `#include <boost/pfr...` is now implicitly does `import boost.pfr` if the modules are supported 
2) CI now tests modules on Ubuntu 24.04 with existing runtime tests
3) Renamed module to `boost.pfr`
4) CMakeLists.txt now uses modules for `Boost::pfr` target if modules are supported
5) All the library internals now have unconditional module level linkage. `1)` allows users to mix `#include <boost/pfr...` and `import boost.pfr` in user code without ODR-violations.

Significant differences from https://anarthal.github.io/cppblog/modules3:
* PFR uses a `BOOST_PFR_USE_STD_MODULE` macro for `import std;` / `includes` while building module. This allows to use `boost.pfr` module in C++20 and even without usable  `std` module.
2025-04-16 09:16:09 +03:00
Antony Polukhin 3fe5ce61ee Update copyright years 2025-01-08 20:27:31 +03:00
Antony Polukhin f09e6aeae9 Fix clang-tidy warnings 2024-10-19 16:25:09 +03:00
Anarthal (Rubén Pérez) 69263f4757 Fix unused warning in fields_count.hpp (#187) 2024-10-15 09:41:21 +03:00
Antony Polukhin 469ac134f3 Micro-optimize PFR fields detection (#188)
* Start upper bound fields search from `4` fields, to avoid slow startup on typical workloads
* Inline the `fields_count_binary_search_unbounded` function to reduce template instantiations depth by 1
* Renamed `min` to `min_of_size_t` to avoid weired syntax
* Applied idea of better error reporting from #120
* Do not start fields count computation if one of the static asserts failed. That speedups error reporting in edge cases
* Use `std::*_t` versions of traits as they are faster in some implementations
* Rewrite binary search to simplify it and to avoid degradation to linear search on types that have constructor from variadic pack
* Remove default template parameters to simplify code

As a result, the whole test suite now runs 10%-25% faster on MSVC, ~20% faster on Clang, and 7%-20% faster on GCC.
2024-10-15 09:39:26 +03:00
Zachary Wassall ff415a26ff Improve field count typical case performance (#120)
The tightest upper bound one can specify on the number of fields in a
struct is `sizeof(type) * CHAR_BIT`. So this was previously used when
performing a binary search for the field count. This upper bound is
extremely loose when considering a typical large struct, which is more
likely to contain a relatively small number of relatively large fields
rather than the other way around. The binary search range being multiple
orders of magnitude larger than necessary wouldn't have been a
significant issue if each test was cheap, but they're not. Testing a
field count of N costs O(N) memory and time. As a result, the initial
few steps of the binary search may be prohibitively expensive.

The primary optimization introduced by these changes is to use unbounded
binary search, a.k.a. exponential search, instead of the typically
loosely bounded binary search. This produces a tight upper bound (within
2x) on the field count to then perform the binary search with.

As an upside of this change, the compiler-specific limit placed on the
upper bound on the field count to stay within compiler limits could be
removed.
2024-10-09 14:12:39 +03:00
Antony Polukhin 8cd1a9675d Merge branch 'develop' of github.com:boostorg/pfr into develop 2024-09-15 19:35:48 +03:00
Antony Polukhin 4d912c1925 Fix warning about GCC not being aware of the -Wundefined-var-template (fixes #166) 2024-09-15 19:35:21 +03:00
Antony Polukhin e1a0832a0e Reflect up to 200 fields by default in c++17 implementation via structured bindings (#181) 2024-09-13 19:15:10 +03:00
Anarthal (Rubén Pérez) 73938e0936 Fix unused warnings in core_name14_disabled.hpp (#183)
Fixes #182
2024-09-13 19:03:12 +03:00
Antony Polukhin e4cbbc78f0 Better headers organization (#180) 2024-09-13 14:24:21 +03:00
Antony Polukhin 6591a8609d Fix pragma directive (fixes #175) 2024-09-13 12:50:43 +03:00
Lena 3d090e7c6f Add function for_each_field_with_name (#171) 2024-09-13 11:57:49 +03:00
Antony Polukhin 60391652fa Initial support for C++20 modules (#177) 2024-08-15 10:59:07 +03:00
Antony Polukhin 449bf360f7 Workaround MSVC bogus warning (fixes #167) 2024-04-01 12:18:52 +03:00
Denis Mikhailov 5f857d5503 Get rid of cast_to_layout_compatible (#154) 2024-02-17 16:47:03 +03:00
Antony Polukhin 9b90f2f6bb CI fixes (#161) 2024-02-16 08:41:05 +03:00
Antony Polukhin 8f3b819b1e Allow throwing exceptions from pfr::structure_to_tuple (fixes #155) … (#160)
…and fix some warnings
2024-02-15 10:10:46 +03:00
Antony Polukhin 4c15f217f4 Merge pull request #152 from schaumb/get_name
Addressing the limitation of get_name
2024-01-28 11:52:57 +03:00
Antony Polukhin 16d771f498 Update copyright years 2024-01-07 13:12:44 +03:00
bela 5b55480c65 Addressing the limitation of get_name 2023-11-30 10:09:09 +01:00
Denis Mikhailov 98789f610a Fix get_name on clang for MSVC (#149) 2023-11-29 09:32:30 +03:00
Denis Mikhailov c695aa0b32 Improve diagnostic for attempt to use get_name with non-external (#146)
Co-authored-by: Antony Polukhin <antoshkka@gmail.com>
2023-11-26 11:52:17 +03:00
Antony Polukhin 2c79036816 Fix an unused parameter warning 2023-09-28 10:00:01 +03:00
denzor200 53fcd78d4f Forbid get_name for arrays 2023-09-23 01:53:00 +03:00
Denis Mikhailov 730f40b6b2 Fix typos (#139) 2023-09-19 11:46:52 +03:00
Antony Polukhin 67f4fc4398 Harden the filed name checks and improve the diagnostics (#138) 2023-09-18 13:57:58 +03:00
Antony Polukhin 7ba81adbd6 Avoid stored_name_of_field duplication in different translation units 2023-09-17 18:06:35 +03:00
Antony Polukhin 27b9706ac5 Fix compilation on MSVC 2023-09-17 14:14:26 +03:00
Antony Polukhin 3f07e7187e relax standard library requirements 2023-09-17 13:41:43 +03:00
denzor200 6dcf66cbd5 Fix for old MSVC compiler 2023-09-10 05:19:20 +03:00
denzor200 8794056e20 review 2023-09-10 04:06:58 +03:00
denzor200 5a7d6524a7 Fix docs 2023-09-09 22:07:12 +03:00
denzor200 0cb5cf2ae7 Fix strip_boost_namespace.sh 2023-09-08 00:49:52 +03:00
denzor200 2c79ac703b Fix CI 2023-09-06 01:52:54 +03:00
denzor200 dbbfa6ea7f Parser might be explicitly tagged as backward 2023-09-03 02:12:25 +03:00
denzor200 fcfca74355 Write docs 2023-09-02 22:42:54 +03:00