2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

support for empty structures in flat_* methods, slightly more compact streaming operators

This commit is contained in:
Antony Polukhin
2016-04-11 20:41:37 +03:00
parent ded8e73866
commit f0a92f01e7
3 changed files with 44 additions and 13 deletions

View File

@@ -124,7 +124,7 @@ auto flat_tie(T& val, typename std::enable_if< std::is_trivially_assignable<T, T
/// Example usage:
/// struct my_struct { int i, short s; };
/// my_struct s{12, 13};
/// flat_write(std::cout, s); // outputs '{ 12, 13 }'
/// flat_write(std::cout, s); // outputs '{12, 13}'
template <class Char, class Traits, class T>
void flat_write(std::basic_ostream<Char, Traits>& out, const T& value);
@@ -134,7 +134,7 @@ void flat_write(std::basic_ostream<Char, Traits>& out, const T& value);
/// struct my_struct { int i, short s; };
/// my_struct s;
/// std::stringstream ss;
/// ss << "{ 12, 13 }";
/// ss << "{12, 13}";
/// ss >> s;
/// assert(s.i == 12);
/// assert(s.i == 13);
@@ -152,7 +152,7 @@ void flat_read(std::basic_istream<Char, Traits>& in, T& value);
/// comparable_struct s1 {0, 1, "Hello", false, 6,7,8,9,10,11};
/// comparable_struct s2 {0, 1, "Hello", false, 6,7,8,9,10,11111};
/// assert(s1 < s2);
/// std::cout << s1 << std::endl; // Outputs: { 0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11 }
/// std::cout << s1 << std::endl; // Outputs: {0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11}
namespace pod_ops;
```