// Copyright 2020 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include #include class X { private: std::pair p_; public: std::pair& f() { return p_; } std::pair const& f() const { return p_; } BOOST_DESCRIBE_CLASS(X, (), ((std::pair& ()) f, (std::pair const& () const) f), (), (p_)) }; #if !defined(BOOST_DESCRIBE_CXX14) #include BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available") int main() {} #else #include int main() { using namespace boost::describe; using namespace boost::mp11; { using L1 = describe_members; BOOST_TEST_EQ( mp_size::value, 1 ); using D1 = mp_at_c; BOOST_TEST_CSTR_EQ( D1::name, "p_" ); BOOST_TEST_EQ( D1::modifiers, mod_private ); X x; auto& p = x.*D1::pointer; using L2 = describe_members; BOOST_TEST_EQ( mp_size::value, 2 ); using D2 = mp_at_c; using D3 = mp_at_c; BOOST_TEST_EQ( &(x.*D2::pointer)(), &p ); BOOST_TEST_CSTR_EQ( D2::name, "f" ); BOOST_TEST_EQ( D2::modifiers, mod_public | mod_function ); BOOST_TEST_EQ( &(x.*D3::pointer)(), &p ); BOOST_TEST_CSTR_EQ( D3::name, "f" ); BOOST_TEST_EQ( D3::modifiers, mod_public | mod_function ); } return boost::report_errors(); } #endif // !defined(BOOST_DESCRIBE_CXX14)