// Copyright 2020 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include using namespace boost::describe; template, class Md = describe_members, class En = std::enable_if_t::value> > std::ostream& operator<<( std::ostream & os, T const & t ) { os << "{"; bool first = true; boost::mp11::mp_for_each([&](auto D){ if( !first ) { os << ", "; } first = false; using B = typename decltype(D)::type; os << (B const&)t; }); boost::mp11::mp_for_each([&](auto D){ if( !first ) { os << ", "; } first = false; os << "." << D.name << " = " << t.*D.pointer; }); os << "}"; return os; } struct X { int m1 = 1; }; BOOST_DESCRIBE_STRUCT(X, (), (m1)) struct Y { int m2 = 2; }; BOOST_DESCRIBE_STRUCT(Y, (), (m2)) class Z: public X, private Y { int m1 = 3; int m2 = 4; BOOST_DESCRIBE_CLASS(Z, (X, Y), (), (), (m1, m2)) }; #include int main() { std::cout << Z() << std::endl; }