Home | Libraries | People | FAQ | More |
BOOST_PFR_FUNCTIONS_FOR
// In header: <boost/pfr/functions_for.hpp>
BOOST_PFR_FUNCTIONS_FOR(T)
Defines comparison and stream operators for T along with hash_value function.
Example:
#include <boost/pfr/functions_for.hpp> 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; }; BOOST_PFR_FUNCTIONS_FOR(comparable_struct) // ... 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}
See Also : 'Three ways of getting operators' for other ways to define operators and more details.
Defines following for T:
bool operator==(const T& lhs, const T& rhs); bool operator!=(const T& lhs, const T& rhs); bool operator< (const T& lhs, const T& rhs); bool operator> (const T& lhs, const T& rhs); bool operator<=(const T& lhs, const T& rhs); bool operator>=(const T& lhs, const T& rhs); template <class Char, class Traits> std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& out, const T& value); template <class Char, class Traits> std::basic_istream<Char, Traits>& operator>>(std::basic_istream<Char, Traits>& in, T& value); // helper function for Boost unordered containers and boost::hash<>. std::size_t hash_value(const T& value);