#include
#include
struct Foo {
int x;
int y;
};
void PrintFoo(const Foo& foo) {
constexpr auto members =
define_static_array(nonstatic_data_members_of(^^Foo, std::meta::access_context::current()));
template for (constexpr auto member : members) {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79823450/is-there-anyway-to-iterate-data-members-with-stl-algorithms-using-the-c26-refl[/url]
С помощью отражения C++26 мы можем просто перебирать все элементы данных объекта: [code]#include #include
struct Foo { int x; int y; };
void PrintFoo(const Foo& foo) { constexpr auto members = define_static_array(nonstatic_data_members_of(^^Foo, std::meta::access_context::current())); template for (constexpr auto member : members) { std::cout