Skip to content

Commit 4a973c5

Browse files
committed
Update docs by not using is_aggregate (fixes #158) and by describing the get_name implementation (fixes #150)
1 parent 4c15f21 commit 4a973c5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: doc/pfr.qbk

+14-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void Write(Writer& writer, int value);
161161
void Write(Writer& writer, std::string_view value);
162162

163163
template <typename T>
164-
std::enable_if_t<std::is_aggregate_v<T>> Write(Writer& writer, const T& value) {
164+
std::enable_if_t<boost::pfr::is_implicitly_reflectable_v<T>> Write(Writer& writer, const T& value) {
165165
boost::pfr::for_each_field(
166166
value, [&writer](const auto& field) { Write(writer, field); });
167167
}
@@ -551,6 +551,8 @@ parameters provided to `BOOST_PFR_CORE_NAME_PARSING` macro [*and] the initial ou
551551

552552
[section How it works]
553553

554+
[h2 Fields count detection and getting references to members]
555+
554556
Short description:
555557

556558
# at compile-time: use aggregate initialization to detect fields count in user-provided structure
@@ -577,6 +579,17 @@ Long description of some basics: [@https://youtu.be/UlNUNxLtBI0 Antony Polukhin:
577579
Long description of some basics of C++14 with [link boost_pfr.limitations_and_configuration [*BOOST_PFR_USE_LOOPHOLE == 0]]: [@https://youtu.be/abdeAew3gmQ Antony Polukhin: C++14 Reflections Without Macros, Markup nor External Tooling].
578580
Description of the [*BOOST_PFR_USE_LOOPHOLE == 1] technique by its inventor Alexandr Poltavsky [@http://alexpolt.github.io/type-loophole.html in his blog].
579581

582+
[h2 Field name retrieval]
583+
584+
# at compile-time:
585+
* Get references to members of an object of type `T` in `constexpr` function
586+
* Feed the reference from previous as a template parameter to a `constexpr` function with `template <auto member_ptr>`.
587+
That function returns `__PRETTY_FUNCTION__` or some other vendor specific macro that prints the whole name of a function
588+
along with the template arguments.
589+
* The returned value from previous step contains the member name ([@https://godbolt.org/z/K4aWdcE9G godbolt example]). Do some
590+
compiler specific parsing of the value and make a `std::string_view` that contains only the member name.
591+
# at run-time: return the `std::string_view` with the member name.
592+
580593
[endsect]
581594

582595
[section Acknowledgements]

0 commit comments

Comments
 (0)