// // Copyright 2012-2019 Antony Polukhin. // // 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 "test_lib.hpp" #include namespace user_defined_namespace { class user_defined{}; } void comparing_types_between_modules() { boost::typeindex::type_index t_const_int = boost::typeindex::type_id_with_cvr(); boost::typeindex::type_index t_int = boost::typeindex::type_id(); BOOST_TEST_EQ(t_int, test_lib::get_integer()); BOOST_TEST_EQ(t_const_int, test_lib::get_const_integer()); BOOST_TEST_NE(t_const_int, test_lib::get_integer()); BOOST_TEST_NE(t_int, test_lib::get_const_integer()); boost::typeindex::type_index t_const_userdef = boost::typeindex::type_id_with_cvr(); boost::typeindex::type_index t_userdef = boost::typeindex::type_id(); BOOST_TEST_EQ(t_userdef, test_lib::get_user_defined_class()); BOOST_TEST_EQ(t_const_userdef, test_lib::get_const_user_defined_class()); BOOST_TEST_NE(t_const_userdef, test_lib::get_user_defined_class()); BOOST_TEST_NE(t_userdef, test_lib::get_const_user_defined_class()); BOOST_TEST_NE(t_userdef, test_lib::get_integer()); BOOST_TEST_NE(t_const_userdef, test_lib::get_integer()); BOOST_TEST_NE(t_int, test_lib::get_user_defined_class()); BOOST_TEST_NE(t_const_int, test_lib::get_const_user_defined_class()); // MSVC supports detect_missmatch pragma, but /GR- silently switch disable the link time check. // /GR- undefies the _CPPRTTI macro. Using it to detect working detect_missmatch pragma. #if !defined(BOOST_HAS_PRAGMA_DETECT_MISMATCH) || !defined(_CPPRTTI) test_lib::accept_typeindex(t_int); #endif } int main() { comparing_types_between_modules(); return boost::report_errors(); }