// Copyright 2021, 2022 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include #include #include #include using namespace boost::describe; namespace app { #if BOOST_VERSION < 108100 template, class Md = describe_members, class En = std::enable_if_t::value> > std::size_t hash_value( T const & t ) { std::size_t r = 0; boost::mp11::mp_for_each([&](auto D){ using B = typename decltype(D)::type; boost::hash_combine( r, (B const&)t ); }); boost::mp11::mp_for_each([&](auto D){ boost::hash_combine( r, t.*D.pointer ); }); return r; } #endif struct A { int x = 1; }; BOOST_DESCRIBE_STRUCT(A, (), (x)) struct B { int y = 2; }; BOOST_DESCRIBE_STRUCT(B, (), (y)) struct C { std::vector> v; }; BOOST_DESCRIBE_STRUCT(C, (), (v)) } // namespace app #include int main() { app::C c; c.v.push_back( app::A{} ); c.v.push_back( app::B{} ); std::cout << boost::hash()( c ) << std::endl; }