compare_ctti_stl.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // Copyright Klemens Morgenstern, 2012-2015.
  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. #include <boost/type_index/ctti_type_index.hpp>
  8. #include <boost/type_index/stl_type_index.hpp>
  9. #include <boost/core/lightweight_test.hpp>
  10. namespace my_namespace1 {
  11. class my_class{};
  12. }
  13. namespace my_namespace2 {
  14. class my_class{};
  15. }
  16. namespace my_namespace3
  17. {
  18. template<typename T, typename U>
  19. struct my_template {};
  20. }
  21. #if !defined( BOOST_NO_RTTI )
  22. template<typename T>
  23. void compare()
  24. {
  25. typedef boost::typeindex::ctti_type_index ctti;
  26. typedef boost::typeindex::stl_type_index stl;
  27. BOOST_TEST_EQ(
  28. ctti::type_id<int>().pretty_name(),
  29. stl::type_id<int>().pretty_name()
  30. );
  31. }
  32. int main()
  33. {
  34. compare<void>();
  35. compare<int>();
  36. compare<double*>();
  37. compare<const double&>();
  38. compare<my_namespace1::my_class>();
  39. compare<my_namespace3::my_template<
  40. my_namespace1::my_class,
  41. my_namespace2::my_class> >();
  42. return boost::report_errors();
  43. }
  44. #else
  45. int main()
  46. {
  47. return 0;
  48. }
  49. #endif