mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
23 lines
611 B
C++
23 lines
611 B
C++
// Copyright (c) 2016-2020 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() {
|
|
using namespace boost::pfr::ops; // out-of-the-box ostream operator for all PODs!
|
|
|
|
my_struct s{100, 'H', 3.141593};
|
|
std::cout << "my_struct has " << boost::pfr::tuple_size<my_struct>::value
|
|
<< " fields: " << s << "\n";
|
|
}
|