1// Copyright (c) 2016-2024 Antony Polukhin
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include <iostream>
7#include "boost/pfr.hpp"
8
9struct my_struct { // no ostream operator defined!
10 std::string s;
11 int i;
12};
13
14int main() {
15 my_struct s{.s: {"Das ist fantastisch!"}, .i: 100};
16
17 std::cout << "my_struct has "
18 << boost::pfr::tuple_size<my_struct>::value // Outputs: 2
19 << " fields: "
20 << boost::pfr::io(value&: s); // Outputs: {"Das ist fantastisch!", 100};
21}
22

source code of boost/libs/pfr/test/core/run/motivating_example2.cpp