// Copyright 2020 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include int main() { { boost::shared_ptr p1( new int ); boost::shared_ptr p2( p1 ); BOOST_TEST( !p1.owner_before( p2 ) ); BOOST_TEST( !p2.owner_before( p1 ) ); boost::shared_ptr p3( new int ); BOOST_TEST( p1.owner_before( p3 ) || p3.owner_before( p1 ) ); boost::shared_ptr p4; boost::shared_ptr p5; BOOST_TEST( !p4.owner_before( p5 ) ); BOOST_TEST( !p5.owner_before( p4 ) ); BOOST_TEST( p4.owner_before( p3 ) || p3.owner_before( p4 ) ); boost::shared_ptr p6( static_cast(0) ); BOOST_TEST( p4.owner_before( p6 ) || p6.owner_before( p4 ) ); boost::shared_ptr p7( p1 ); BOOST_TEST( !p1.owner_before( p7 ) ); BOOST_TEST( !p7.owner_before( p1 ) ); boost::shared_ptr p8; BOOST_TEST( p1.owner_before( p8 ) || p8.owner_before( p1 ) ); BOOST_TEST( !p4.owner_before( p8 ) ); BOOST_TEST( !p8.owner_before( p4 ) ); boost::weak_ptr q1( p1 ); BOOST_TEST( !p1.owner_before( q1 ) ); BOOST_TEST( !q1.owner_before( p1 ) ); boost::weak_ptr q2( p1 ); BOOST_TEST( !q1.owner_before( q2 ) ); BOOST_TEST( !q2.owner_before( q1 ) ); boost::weak_ptr q3( p3 ); BOOST_TEST( p1.owner_before( q3 ) || q3.owner_before( p1 ) ); BOOST_TEST( q1.owner_before( q3 ) || q3.owner_before( q1 ) ); boost::weak_ptr q4; BOOST_TEST( !p4.owner_before( q4 ) ); BOOST_TEST( !q4.owner_before( p4 ) ); BOOST_TEST( q1.owner_before( q4 ) || q4.owner_before( q1 ) ); boost::weak_ptr q5; BOOST_TEST( !q4.owner_before( q5 ) ); BOOST_TEST( !q5.owner_before( q4 ) ); boost::weak_ptr q7( p7 ); BOOST_TEST( !p1.owner_before( q7 ) ); BOOST_TEST( !q7.owner_before( p1 ) ); BOOST_TEST( !q1.owner_before( q7 ) ); BOOST_TEST( !q7.owner_before( q1 ) ); p1.reset(); p2.reset(); p3.reset(); p7.reset(); BOOST_TEST( q1.expired() ); BOOST_TEST( q2.expired() ); BOOST_TEST( q3.expired() ); BOOST_TEST( q7.expired() ); BOOST_TEST( !q1.owner_before( q2 ) ); BOOST_TEST( !q2.owner_before( q1 ) ); BOOST_TEST( !q1.owner_before( q7 ) ); BOOST_TEST( !q7.owner_before( q1 ) ); BOOST_TEST( q1.owner_before( q3 ) || q3.owner_before( q1 ) ); BOOST_TEST( q1.owner_before( q4 ) || q4.owner_before( q1 ) ); } return boost::report_errors(); }