Home | Libraries | People | FAQ | More |
boost::pfr::io_fields
// In header: <boost/pfr/io_fields.hpp> template<typename T> auto io_fields(T && value);
IO manipulator to read/write simple aggregate value
field-by-field.
Example:
struct my_struct { int i; short s; }; std::ostream& operator<<(std::ostream& os, const my_struct& x) { return os << boost::pfr::io_fields(x); // Equivalent to: os << "{ " << x.i << " ," << x.s << " }" } std::istream& operator>>(std::istream& is, my_struct& x) { return is >> boost::pfr::io_fields(x); // Equivalent to: is >> "{ " >> x.i >> " ," >> x.s >> " }" }
Input and output streaming operators for boost::pfr::io_fields
are symmetric, meaning that you get the original value by streaming it and reading back if each fields streaming operator is symmetric.
See Also : 'Custom printing of aggregates' for info on how to implement your own manipulator with custom format.