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// requires: C++14
7#include <iostream>
8#include "boost/pfr.hpp"
9
10struct my_struct { // no ostream operator defined!
11 int i;
12 char c;
13 double d;
14};
15
16int main() {
17 my_struct s{.i: 100, .c: 'H', .d: 3.141593};
18 std::cout << "my_struct has "
19 << boost::pfr::tuple_size<my_struct>::value // Outputs: 3
20 << " fields: "
21 << boost::pfr::io(value&: s); // Outputs: {100, 'H', 3.141593}
22}
23

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