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