23 lines
595 B
C++
23 lines
595 B
C++
// Copyright (c) 2016-2021 Antony Polukhin
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
// requires: C++14
|
|
#include <iostream>
|
|
#include "boost/pfr.hpp"
|
|
|
|
struct my_struct { // no ostream operator defined!
|
|
int i;
|
|
char c;
|
|
double d;
|
|
};
|
|
|
|
int main() {
|
|
my_struct s{100, 'H', 3.141593};
|
|
std::cout << "my_struct has "
|
|
<< boost::pfr::tuple_size<my_struct>::value // Outputs: 3
|
|
<< " fields: "
|
|
<< boost::pfr::io(s); // Outputs: {100, 'H', 3.141593}
|
|
}
|