1 // Copyright Klemens Morgenstern, 2012-2015. 2 // Copyright 2019-2021 Antony Polukhin. 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See 5 // accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 8 #include <boost/type_index/ctti_type_index.hpp> 9 #include <boost/type_index/stl_type_index.hpp> 10 #include <boost/core/lightweight_test.hpp> 11 12 13 namespace my_namespace1 { 14 class my_class{}; 15 } 16 17 18 namespace my_namespace2 { 19 class my_class{}; 20 } 21 22 namespace my_namespace3 23 { 24 template<typename T, typename U> 25 struct my_template {}; 26 27 } 28 29 #if !defined( BOOST_NO_RTTI ) 30 31 template<typename T> compare()32void compare() 33 { 34 typedef boost::typeindex::ctti_type_index ctti; 35 typedef boost::typeindex::stl_type_index stl; 36 BOOST_TEST_EQ( 37 ctti::type_id<int>().pretty_name(), 38 stl::type_id<int>().pretty_name() 39 ); 40 } 41 42 main()43int main() 44 { 45 compare<void>(); 46 compare<int>(); 47 compare<double*>(); 48 compare<const double&>(); 49 compare<my_namespace1::my_class>(); 50 51 compare<my_namespace3::my_template< 52 my_namespace1::my_class, 53 my_namespace2::my_class> >(); 54 55 56 return boost::report_errors(); 57 } 58 59 #else 60 main()61int main() 62 { 63 return 0; 64 } 65 66 #endif 67 68