вт, 6 окт. 2020 г. в 14:42, Andrzej Krzemienski via Boost
wt., 6 paź 2020 o 13:29 Peter Dimov via Boost
napisał(a): Andrzej Krzemienski wrote:
3. The library buds on a basic concept of "Base-less aggregate".
That's not really true though, is it? E.g.
#include
#include <string> #include <iostream> struct X { std::string a; };
struct Y { std::string b; };
struct Z: X, Y { std::string c; };
int main() { std::cout << boost::pfr::tuple_size_v<Z> << std::endl; }
compiles and prints "3". Bases are treated as members by the precise API.
But this is only for tuple_size. If you do a for_each, the compilation breaks:
``` Z z {{}, {}, {}}; boost::pfr::for_each_field(z, [](auto const&){}); ```
This is because brace initialization of aggregates is "incompatible" with structured binding for aggregates now in C++20.
I think we took the wrong turn in C++17, when allowed inheritance for aggregates. Unfortunately that's not getting better with time :( -- Best regards, Antony Polukhin