Как это работает в boost/pfr?
#include <boost/pfr.hpp>
#include <iostream>
#include <tuple>
struct MyStruct {
int a;
float b;
double c;
};
int main() {
MyStruct s{1, 2.0f, 3.0};
// Получение значения полей по индексу
std::cout << boost::pfr::get<0>(s) << std::endl; // Выводит: 1
std::cout << boost::pfr::get<1>(s) << std::endl; // Выводит: 2.0
std::cout << boost::pfr::get<2>(s) << std::endl; // Выводит: 3.0
// Итерация по полям с использованием std::tuple
boost::pfr::for_each_field(s, [](const auto& field) {
std::cout << field << std::endl;
});
return 0;
}
?
Как примерно это возможно?