// // pointer_to_other_test.cpp - a test for boost/pointer_to_other.hpp // // Copyright (c) 2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #include #include #include #include #include #include #include #include template void assert_same_type( T** pt = 0, U** pu = 0 ) { pt = pu; } struct X; struct Y; int main() { // shared_ptr assert_same_type< boost::pointer_to_other< boost::shared_ptr, Y >::type, boost::shared_ptr >(); assert_same_type< boost::pointer_to_other< boost::shared_ptr, void >::type, boost::shared_ptr >(); assert_same_type< boost::pointer_to_other< boost::shared_ptr, Y >::type, boost::shared_ptr >(); // shared_array assert_same_type< boost::pointer_to_other< boost::shared_array, Y >::type, boost::shared_array >(); assert_same_type< boost::pointer_to_other< boost::shared_array, void >::type, boost::shared_array >(); assert_same_type< boost::pointer_to_other< boost::shared_array, Y >::type, boost::shared_array >(); // scoped_ptr assert_same_type< boost::pointer_to_other< boost::scoped_ptr, Y >::type, boost::scoped_ptr >(); assert_same_type< boost::pointer_to_other< boost::scoped_ptr, void >::type, boost::scoped_ptr >(); assert_same_type< boost::pointer_to_other< boost::scoped_ptr, Y >::type, boost::scoped_ptr >(); // scoped_array assert_same_type< boost::pointer_to_other< boost::scoped_array, Y >::type, boost::scoped_array >(); assert_same_type< boost::pointer_to_other< boost::scoped_array, void >::type, boost::scoped_array >(); assert_same_type< boost::pointer_to_other< boost::scoped_array, Y >::type, boost::scoped_array >(); // intrusive_ptr assert_same_type< boost::pointer_to_other< boost::intrusive_ptr, Y >::type, boost::intrusive_ptr >(); assert_same_type< boost::pointer_to_other< boost::intrusive_ptr, void >::type, boost::intrusive_ptr >(); assert_same_type< boost::pointer_to_other< boost::intrusive_ptr, Y >::type, boost::intrusive_ptr >(); #if !defined( BOOST_NO_AUTO_PTR ) // auto_ptr assert_same_type< boost::pointer_to_other< std::auto_ptr, Y >::type, std::auto_ptr >(); assert_same_type< boost::pointer_to_other< std::auto_ptr, void >::type, std::auto_ptr >(); assert_same_type< boost::pointer_to_other< std::auto_ptr, Y >::type, std::auto_ptr >(); #endif // raw pointer assert_same_type< boost::pointer_to_other< X *, Y >::type, Y * >(); assert_same_type< boost::pointer_to_other< X *, void >::type, void * >(); assert_same_type< boost::pointer_to_other< void *, Y >::type, Y * >(); return 0; }