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

Operators in pod_ops namespace are now disabled for POD type if that POD type could be implicitly converted to type that has required operator (fixes output of 'using namespace pod_ops; std::cout << std::true_type{};')

This commit is contained in:
Antony Polukhin
2016-04-12 21:53:03 +03:00
parent f0a92f01e7
commit 0127ec9f8e
3 changed files with 118 additions and 38 deletions

View File

@@ -142,17 +142,19 @@ template <class Char, class Traits, class T>
void flat_read(std::basic_istream<Char, Traits>& in, T& value);
/// Contains comparison operators and stream operators for any POD types
/// Contains comparison operators and stream operators for any POD types that does not have it's own operators.
/// If POD is comparable or streamable using it's own operator or it's conversion operator, then the original operator is be used.
///
/// Example usage:
/// struct comparable_struct {
/// struct comparable_struct { // No operators defined for that structure
/// int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
/// }; // No operators defined for that structure
/// };
/// using namespace pod_ops;
///
/// 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;
```