diff --git a/README.md b/README.md index 9490cee..9333842 100644 --- a/README.md +++ b/README.md @@ -164,87 +164,6 @@ namespace pod_ops; * Enums will be returned as their underlying type * Static variables are ignored - -### Cool usecase examples - -* Auto generate comparisons: -```c++ -namespace pod_ops { // Contains comparisons suitable for any POD type - -template -inline bool operator==(const T1& lhs, const T2& rhs) { - return flat_make_tuple(lhs) == flat_make_tuple(rhs); -} - -template -inline bool operator!=(const T1& lhs, const T2& rhs) { - return flat_make_tuple(lhs) != flat_make_tuple(rhs); -} - -template -inline bool operator<(const T1& lhs, const T2& rhs) { - return flat_make_tuple(lhs) < flat_make_tuple(rhs); -} - -template -inline bool operator>(const T1& lhs, const T2& rhs) { - return flat_make_tuple(lhs) > flat_make_tuple(rhs); -} - -} // pod_ops - -// ... - -struct comparable_struct { - int i; short s; char data[7]; bool bl; int a,b,c,d,e,f; -}; // No `operator ==` or `operator<` defined for the 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 == s1); // uses pod_ops::operator== -assert(s1 < sq); // uses pod_ops::operator< - -``` - -* Universal ostream operator<<: -```c++ -template -struct print_impl { - template - static void print (std::ostream& out, const T& value) { - if (!!I) out << ", "; - out << flat_get(value); - print_impl::print(out, value); - } -}; - -template -struct print_impl { - template static void print (std::ostream&, const T&) {} -}; - -// Universal `operator <<` for all POD types -template -typename std::enable_if::value && std::is_class::value, Ostreamable& >::type - operator<<(Ostreamable& out, const T& value) -{ - out << boost::typeindex::type_id().pretty_name() << " { "; - print_impl<0, flat_tuple_size_v >::print(out, value); - out << " };"; - return out; -} - -// ... - - // No `operator<<` defined for that structure: -comparable_struct s1 {0, 1, "Hello", false, 6,7,8,9,10,11}; - -// Using universal operator<< -std::cout << s1 << std::endl; // Outputs: { 0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11 } -``` - ### License Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).