testing_crossmodule_anonymous.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Copyright 2012-2019 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. #include <boost/core/lightweight_test.hpp>
  8. #include <boost/type_index.hpp>
  9. #include "test_lib_anonymous.hpp"
  10. #include <iostream>
  11. #define BOOST_CHECK_NE(x, y) BOOST_CHECK(x != y)
  12. namespace {
  13. class user_defined{};
  14. }
  15. void comparing_anonymous_types_between_modules()
  16. {
  17. boost::typeindex::type_index t_const_userdef = boost::typeindex::type_id_with_cvr<const user_defined>();
  18. boost::typeindex::type_index t_userdef = boost::typeindex::type_id<user_defined>();
  19. // Known to fail on Clang and old versions of GCC.
  20. //BOOST_TEST_NE(t_userdef, test_lib::get_anonymous_user_defined_class());
  21. //BOOST_TEST_NE(t_const_userdef, test_lib::get_const_anonymous_user_defined_class());
  22. std::cout
  23. << "t_userdef == " << t_userdef
  24. << ", test_lib::get_anonymous_user_defined_class() == " << test_lib::get_anonymous_user_defined_class()
  25. << '\n';
  26. std::cout
  27. << "t_const_userdef == " << t_const_userdef
  28. << ", test_lib::get_const_anonymous_user_defined_class() == " << test_lib::get_const_anonymous_user_defined_class()
  29. << '\n';
  30. BOOST_TEST_NE(t_const_userdef, test_lib::get_anonymous_user_defined_class());
  31. BOOST_TEST_NE(t_userdef, test_lib::get_const_anonymous_user_defined_class());
  32. }
  33. int main() {
  34. comparing_anonymous_types_between_modules();
  35. return boost::report_errors();
  36. }