#include #include #include #include #include #include #include #include namespace fusion = boost::fusion; struct foo { std::string a; std::string b; }; BOOST_FUSION_ADAPT_STRUCT( foo, (std::string, a) (std::string, b) ) // looks complicated and inflexible bool operator==( const foo& lhs, const foo& rhs ) { using namespace fusion; typedef fusion::vector< const std::string&, const std::string& > fusion_foo_type; fusion_foo_type lhs_ = fusion::vector_tie( lhs.a, lhs.b ); fusion_foo_type rhs_ = fusion::vector_tie( rhs.a, rhs.b ); return lhs_ == rhs_; } template struct foo_struct_iterator : boost::fusion::iterator_base > { BOOST_STATIC_ASSERT(Pos >=0 && Pos < 2); typedef Struct struct_type; typedef boost::mpl::int_ index; typedef boost::fusion::random_access_traversal_tag category; foo_struct_iterator(Struct& str) : struct_(str) {} Struct& struct_; }; int main() { using namespace boost::fusion; foo h1, h2, h3; h1.a = "Foo"; h2.a = "Foo"; h3.a = "Bar"; std::cout << "h1 == h2: " << std::boolalpha << ( h1 == h2 ) << std::endl; std::cout << "h1 == h3: " << std::boolalpha << ( h1 == h3 ) << std::endl; }