summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/type_index/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/type_index/test')
-rw-r--r--src/boost/libs/type_index/test/Jamfile.v281
-rw-r--r--src/boost/libs/type_index/test/compare_ctti_stl.cpp67
-rw-r--r--src/boost/libs/type_index/test/ctti_print_name.cpp44
-rw-r--r--src/boost/libs/type_index/test/test_lib.cpp40
-rw-r--r--src/boost/libs/type_index/test/test_lib.hpp42
-rw-r--r--src/boost/libs/type_index/test/test_lib_anonymous.cpp27
-rw-r--r--src/boost/libs/type_index/test/test_lib_anonymous.hpp34
-rw-r--r--src/boost/libs/type_index/test/testing_crossmodule.cpp57
-rw-r--r--src/boost/libs/type_index/test/testing_crossmodule_anonymous.cpp48
-rw-r--r--src/boost/libs/type_index/test/track_13621.cpp23
-rw-r--r--src/boost/libs/type_index/test/type_index_constexpr_test.cpp157
-rw-r--r--src/boost/libs/type_index/test/type_index_runtime_cast_test.cpp296
-rw-r--r--src/boost/libs/type_index/test/type_index_test.cpp400
-rw-r--r--src/boost/libs/type_index/test/type_index_test_ctti_alignment.cpp18
-rw-r--r--src/boost/libs/type_index/test/type_index_test_ctti_construct_fail.cpp15
-rw-r--r--src/boost/libs/type_index/test/type_index_test_ctti_copy_fail.cpp15
16 files changed, 1364 insertions, 0 deletions
diff --git a/src/boost/libs/type_index/test/Jamfile.v2 b/src/boost/libs/type_index/test/Jamfile.v2
new file mode 100644
index 000000000..22779cbce
--- /dev/null
+++ b/src/boost/libs/type_index/test/Jamfile.v2
@@ -0,0 +1,81 @@
+# Copyright 2012-2020 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)
+#
+
+import testing ;
+import feature ;
+import os ;
+
+# Variable that contains all the stuff required for linking together <rtti>on and <rtti>off
+compat = <define>BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY ;
+
+# Making own `nortti` that is link compatible.
+# We explicitly define BOOST_NO_RTTI because it sometimes can not be detected by build system.
+nortti = <toolset>gcc:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>clang:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>intel:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>darwin:<cxxflags>"-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>msvc:<cxxflags>"/GR-" ;
+
+norttidefines = <toolset>gcc:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>clang:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>intel:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>darwin:<cxxflags>"-DBOOST_NO_RTTI -DBOOST_NO_TYPEID" <toolset>msvc:<cxxflags>"-DBOOST_NO_RTTI" ;
+
+
+# Making libraries that CANNOT work between rtti-on/rtti-off modules
+obj test_lib_nortti-obj : test_lib.cpp : <link>shared <rtti>off $(norttidefines) ;
+obj test_lib_anonymous_nortti-obj : test_lib_anonymous.cpp : <link>shared <rtti>off $(norttidefines) ;
+lib test_lib_nortti : test_lib_nortti-obj : <link>shared <rtti>off $(norttidefines) ;
+lib test_lib_anonymous_nortti : test_lib_anonymous_nortti-obj : <link>shared <rtti>off $(norttidefines) ;
+
+obj test_lib_rtti-obj : test_lib.cpp : <link>shared ;
+obj test_lib_anonymous_rtti-obj : test_lib_anonymous.cpp : <link>shared ;
+lib test_lib_rtti : test_lib_rtti-obj : <link>shared ;
+lib test_lib_anonymous_rtti : test_lib_anonymous_rtti-obj : <link>shared ;
+
+# Making libraries that can work between rtti-on/rtti-off modules
+obj test_lib_nortti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ;
+obj test_lib_rtti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ;
+lib test_lib_nortti_compat : test_lib_nortti_compat-obj : <link>shared $(nortti) $(compat) ;
+lib test_lib_rtti_compat : test_lib_rtti_compat-obj : <link>shared $(nortti) $(compat) ;
+
+exe testing_crossmodule_anonymous_no_rtti : testing_crossmodule_anonymous.cpp test_lib_anonymous_nortti : <rtti>off $(norttidefines) ;
+
+test-suite type_index
+ :
+ [ run type_index_test.cpp ]
+ [ run type_index_runtime_cast_test.cpp ]
+ [ run type_index_constexpr_test.cpp ]
+ [ run type_index_test.cpp : : : <rtti>off $(norttidefines) : type_index_test_no_rtti ]
+ [ run ctti_print_name.cpp : : : <test-info>always_show_run_output ]
+ [ run testing_crossmodule.cpp test_lib_rtti ]
+ [ run testing_crossmodule.cpp test_lib_nortti : : : <rtti>off $(norttidefines) : testing_crossmodule_no_rtti ]
+ [ run testing_crossmodule_anonymous.cpp test_lib_anonymous_rtti : : : <test-info>always_show_run_output ]
+ [ run compare_ctti_stl.cpp ]
+ [ run track_13621.cpp ]
+
+ [ compile-fail type_index_test_ctti_copy_fail.cpp ]
+ [ compile-fail type_index_test_ctti_construct_fail.cpp ]
+ [ compile type_index_test_ctti_alignment.cpp ]
+
+ # Mixing RTTI on and off
+
+ # MSVC sometimes overrides the /GR-, without `detect_missmatch` this test may link.
+ # TODO: Disabled on MSVC. Enable again when there'll be an understanding of how to write this test correctly wor MSVC.
+ [ link-fail testing_crossmodule.cpp test_lib_rtti : $(nortti) <toolset>msvc:<build>no : link_fail_nortti_rtti ]
+ [ link-fail testing_crossmodule.cpp test_lib_nortti : <toolset>msvc:<build>no : link_fail_rtti_nortti ]
+
+ [ run testing_crossmodule.cpp test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ]
+ [ run testing_crossmodule.cpp test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ]
+ ;
+
+# Assuring that examples compile and run. Adding sources from `examples` directory to the `type_index` test suite.
+for local p in [ glob ../examples/*.cpp ]
+{
+ # RTTI on
+ type_index += [ run $(p) ] ;
+
+ # RTTI off
+ local target_name = $(p[1]:B)_no_rtti ;
+ if $(target_name) != "table_of_names_no_rtti"
+ {
+ type_index += [ run $(p) : : : <rtti>off $(norttidefines) : $(target_name) ] ;
+ }
+}
+
diff --git a/src/boost/libs/type_index/test/compare_ctti_stl.cpp b/src/boost/libs/type_index/test/compare_ctti_stl.cpp
new file mode 100644
index 000000000..c7f2ec30d
--- /dev/null
+++ b/src/boost/libs/type_index/test/compare_ctti_stl.cpp
@@ -0,0 +1,67 @@
+// Copyright Klemens Morgenstern, 2012-2015.
+// Copyright 2019-2020 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 <boost/type_index/ctti_type_index.hpp>
+#include <boost/type_index/stl_type_index.hpp>
+#include <boost/core/lightweight_test.hpp>
+
+
+namespace my_namespace1 {
+ class my_class{};
+}
+
+
+namespace my_namespace2 {
+ class my_class{};
+}
+
+namespace my_namespace3
+{
+template<typename T, typename U>
+struct my_template {};
+
+}
+
+#if !defined( BOOST_NO_RTTI )
+
+template<typename T>
+void compare()
+{
+ typedef boost::typeindex::ctti_type_index ctti;
+ typedef boost::typeindex::stl_type_index stl;
+ BOOST_TEST_EQ(
+ ctti::type_id<int>().pretty_name(),
+ stl::type_id<int>().pretty_name()
+ );
+}
+
+
+int main()
+{
+ compare<void>();
+ compare<int>();
+ compare<double*>();
+ compare<const double&>();
+ compare<my_namespace1::my_class>();
+
+ compare<my_namespace3::my_template<
+ my_namespace1::my_class,
+ my_namespace2::my_class> >();
+
+
+ return boost::report_errors();
+}
+
+#else
+
+int main()
+{
+ return 0;
+}
+
+#endif
+
diff --git a/src/boost/libs/type_index/test/ctti_print_name.cpp b/src/boost/libs/type_index/test/ctti_print_name.cpp
new file mode 100644
index 000000000..c16c8b465
--- /dev/null
+++ b/src/boost/libs/type_index/test/ctti_print_name.cpp
@@ -0,0 +1,44 @@
+//
+// Copyright 2012-2020 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 <iostream>
+
+// This cpp file:
+// * tests BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING macro
+// * outputs full ctti name so that TypeIndex library could be adjust to new compiler without requesting regression tester's help
+#define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING (0,0,false,"")
+#include <boost/type_index/ctti_type_index.hpp>
+
+namespace user_defined_namespace {
+ class user_defined_class {};
+}
+
+class empty
+{
+};
+
+
+int main()
+{
+ using namespace boost::typeindex;
+
+ std::cout << "int: "
+ << ctti_type_index::type_id<int>() << '\n';
+
+ std::cout << "double: "
+ << ctti_type_index::type_id<double>() << '\n';
+
+ std::cout << "user_defined_namespace::user_defined_class: "
+ << ctti_type_index::type_id<user_defined_namespace::user_defined_class>() << '\n';
+
+
+ std::cout << "empty:"
+ << ctti_type_index::type_id<empty>() << '\n';
+
+ return 0;
+}
+
diff --git a/src/boost/libs/type_index/test/test_lib.cpp b/src/boost/libs/type_index/test/test_lib.cpp
new file mode 100644
index 000000000..174a7fecf
--- /dev/null
+++ b/src/boost/libs/type_index/test/test_lib.cpp
@@ -0,0 +1,40 @@
+//
+// Copyright 2012-2020 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)
+//
+
+#define TEST_LIB_SOURCE
+#include "test_lib.hpp"
+
+namespace user_defined_namespace {
+ class user_defined{};
+}
+
+namespace test_lib {
+
+boost::typeindex::type_index get_integer() {
+ return boost::typeindex::type_id<int>();
+}
+
+boost::typeindex::type_index get_user_defined_class() {
+ return boost::typeindex::type_id<user_defined_namespace::user_defined>();
+}
+
+boost::typeindex::type_index get_const_integer() {
+ return boost::typeindex::type_id_with_cvr<const int>();
+}
+
+boost::typeindex::type_index get_const_user_defined_class() {
+ return boost::typeindex::type_id_with_cvr<const user_defined_namespace::user_defined>();
+}
+
+#if !defined(BOOST_HAS_PRAGMA_DETECT_MISMATCH) || !defined(_CPPRTTI)
+// Just do nothing
+void accept_typeindex(const boost::typeindex::type_index&) {}
+#endif
+
+}
+
diff --git a/src/boost/libs/type_index/test/test_lib.hpp b/src/boost/libs/type_index/test/test_lib.hpp
new file mode 100644
index 000000000..7619008fe
--- /dev/null
+++ b/src/boost/libs/type_index/test/test_lib.hpp
@@ -0,0 +1,42 @@
+//
+// Copyright 2012-2020 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)
+//
+
+#ifndef BOOST_TYPE_INDEX_TESTS_TEST_LIB_HPP
+#define BOOST_TYPE_INDEX_TESTS_TEST_LIB_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+#include <boost/type_index.hpp>
+
+// This is ALWAYS a dynamic library
+#if defined(TEST_LIB_SOURCE)
+# define TEST_LIB_DECL BOOST_SYMBOL_EXPORT
+# else
+# define TEST_LIB_DECL BOOST_SYMBOL_IMPORT
+# endif
+
+namespace test_lib {
+
+TEST_LIB_DECL boost::typeindex::type_index get_integer();
+TEST_LIB_DECL boost::typeindex::type_index get_user_defined_class();
+
+TEST_LIB_DECL boost::typeindex::type_index get_const_integer();
+TEST_LIB_DECL boost::typeindex::type_index get_const_user_defined_class();
+
+#if !defined(BOOST_HAS_PRAGMA_DETECT_MISMATCH) || !defined(_CPPRTTI)
+// This is required for checking RTTI on/off linkage
+TEST_LIB_DECL void accept_typeindex(const boost::typeindex::type_index&);
+#endif
+
+}
+
+#endif // BOOST_TYPE_INDEX_TESTS_LIB1_HPP
+
diff --git a/src/boost/libs/type_index/test/test_lib_anonymous.cpp b/src/boost/libs/type_index/test/test_lib_anonymous.cpp
new file mode 100644
index 000000000..53f4307d4
--- /dev/null
+++ b/src/boost/libs/type_index/test/test_lib_anonymous.cpp
@@ -0,0 +1,27 @@
+//
+// Copyright 2012-2020 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)
+//
+
+#define TEST_LIB_SOURCE
+#include "test_lib_anonymous.hpp"
+
+namespace {
+ class user_defined{};
+} // anonymous namespace
+
+namespace test_lib {
+
+boost::typeindex::type_index get_anonymous_user_defined_class() {
+ return boost::typeindex::type_id<user_defined>();
+}
+
+boost::typeindex::type_index get_const_anonymous_user_defined_class() {
+ return boost::typeindex::type_id_with_cvr<const user_defined>();
+}
+
+}
+
diff --git a/src/boost/libs/type_index/test/test_lib_anonymous.hpp b/src/boost/libs/type_index/test/test_lib_anonymous.hpp
new file mode 100644
index 000000000..15165eb1b
--- /dev/null
+++ b/src/boost/libs/type_index/test/test_lib_anonymous.hpp
@@ -0,0 +1,34 @@
+//
+// Copyright 2012-2020 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)
+//
+
+#ifndef BOOST_TYPE_INDEX_TESTS_TEST_LIB_ANONYMOUS_HPP
+#define BOOST_TYPE_INDEX_TESTS_TEST_LIB_ANONYMOUS_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+#include <boost/type_index.hpp>
+
+// This is ALWAYS a dynamic library
+#if defined(TEST_LIB_SOURCE)
+# define TEST_LIB_DECL BOOST_SYMBOL_EXPORT
+# else
+# define TEST_LIB_DECL BOOST_SYMBOL_IMPORT
+# endif
+
+namespace test_lib {
+
+TEST_LIB_DECL boost::typeindex::type_index get_anonymous_user_defined_class();
+TEST_LIB_DECL boost::typeindex::type_index get_const_anonymous_user_defined_class();
+
+}
+
+#endif // BOOST_TYPE_INDEX_TESTS_TEST_LIB_ANONYMOUS_HPP
+
diff --git a/src/boost/libs/type_index/test/testing_crossmodule.cpp b/src/boost/libs/type_index/test/testing_crossmodule.cpp
new file mode 100644
index 000000000..fa9017d96
--- /dev/null
+++ b/src/boost/libs/type_index/test/testing_crossmodule.cpp
@@ -0,0 +1,57 @@
+//
+// Copyright 2012-2020 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 <boost/type_index.hpp>
+#include "test_lib.hpp"
+
+#include <boost/core/lightweight_test.hpp>
+
+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<const int>();
+ boost::typeindex::type_index t_int = boost::typeindex::type_id<int>();
+
+ 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<const user_defined_namespace::user_defined>();
+ boost::typeindex::type_index t_userdef
+ = boost::typeindex::type_id<user_defined_namespace::user_defined>();
+
+ 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();
+}
+
diff --git a/src/boost/libs/type_index/test/testing_crossmodule_anonymous.cpp b/src/boost/libs/type_index/test/testing_crossmodule_anonymous.cpp
new file mode 100644
index 000000000..f32a69596
--- /dev/null
+++ b/src/boost/libs/type_index/test/testing_crossmodule_anonymous.cpp
@@ -0,0 +1,48 @@
+//
+// Copyright 2012-2020 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 <boost/core/lightweight_test.hpp>
+
+#include <boost/type_index.hpp>
+#include "test_lib_anonymous.hpp"
+
+#include <iostream>
+
+#define BOOST_CHECK_NE(x, y) BOOST_CHECK(x != y)
+
+namespace {
+ class user_defined{};
+}
+
+void comparing_anonymous_types_between_modules()
+{
+ boost::typeindex::type_index t_const_userdef = boost::typeindex::type_id_with_cvr<const user_defined>();
+ boost::typeindex::type_index t_userdef = boost::typeindex::type_id<user_defined>();
+
+ // Known to fail on Clang and old versions of GCC.
+ //BOOST_TEST_NE(t_userdef, test_lib::get_anonymous_user_defined_class());
+ //BOOST_TEST_NE(t_const_userdef, test_lib::get_const_anonymous_user_defined_class());
+
+ std::cout
+ << "t_userdef == " << t_userdef
+ << ", test_lib::get_anonymous_user_defined_class() == " << test_lib::get_anonymous_user_defined_class()
+ << '\n';
+ std::cout
+ << "t_const_userdef == " << t_const_userdef
+ << ", test_lib::get_const_anonymous_user_defined_class() == " << test_lib::get_const_anonymous_user_defined_class()
+ << '\n';
+
+ BOOST_TEST_NE(t_const_userdef, test_lib::get_anonymous_user_defined_class());
+ BOOST_TEST_NE(t_userdef, test_lib::get_const_anonymous_user_defined_class());
+}
+
+int main() {
+ comparing_anonymous_types_between_modules();
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/type_index/test/track_13621.cpp b/src/boost/libs/type_index/test/track_13621.cpp
new file mode 100644
index 000000000..31d4c53f6
--- /dev/null
+++ b/src/boost/libs/type_index/test/track_13621.cpp
@@ -0,0 +1,23 @@
+//
+// Copyright 2018-2020 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 <boost/type_index/ctti_type_index.hpp>
+#include <string>
+
+#include <boost/core/lightweight_test.hpp>
+
+class empty
+{
+};
+
+int main()
+{
+ std::string name = boost::typeindex::ctti_type_index::type_id<empty>().pretty_name();
+ BOOST_TEST(name.find("empty") != std::string::npos);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/type_index/test/type_index_constexpr_test.cpp b/src/boost/libs/type_index/test/type_index_constexpr_test.cpp
new file mode 100644
index 000000000..e9b84eaa6
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_constexpr_test.cpp
@@ -0,0 +1,157 @@
+//
+// Copyright 2015-2020 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 <boost/type_index/ctti_type_index.hpp>
+
+#include <algorithm>
+#include <string>
+
+#include <boost/core/lightweight_test.hpp>
+
+const char* hello1 = "Hello word";
+const char* hello1_end = hello1 + sizeof("Hello word");
+const char* hello2 = "Hello word, pal!";
+const char* hello2_end = hello2 + sizeof("Hello word, pal!");
+
+void strcmp_same() {
+ using boost::typeindex::detail::constexpr_strcmp;
+
+ BOOST_TEST(
+ constexpr_strcmp(hello1, hello1) == 0
+ );
+
+ BOOST_TEST(
+ constexpr_strcmp(hello2, hello2) == 0
+ );
+
+ BOOST_TEST(
+ constexpr_strcmp(hello1, hello2) != 0
+ );
+
+ BOOST_TEST(
+ constexpr_strcmp(hello2, hello1) != 0
+ );
+
+ BOOST_TEST(
+ (constexpr_strcmp(hello2, hello1) < 0)
+ ==
+ (std::strcmp(hello2, hello1) < 0)
+ );
+
+ BOOST_TEST(
+ (constexpr_strcmp(hello1, hello2) < 0)
+ ==
+ (std::strcmp(hello1, hello2) < 0)
+ );
+}
+
+void search_same() {
+ using boost::typeindex::detail::constexpr_search;
+ BOOST_TEST(
+ constexpr_search(hello1, hello1_end, hello2, hello2_end) == std::search(hello1, hello1_end, hello2, hello2_end)
+ );
+
+ BOOST_TEST(
+ constexpr_search(hello2, hello2_end, hello1, hello1_end) == std::search(hello2, hello2_end, hello1, hello1_end)
+ );
+
+ const char* word = "word";
+ const char* word_end = word + sizeof("word") - 1;
+ BOOST_TEST(
+ constexpr_search(hello1, hello1_end, word, word_end) == std::search(hello1, hello1_end, word, word_end)
+ );
+
+ BOOST_TEST(
+ constexpr_search(hello2, hello2_end, word, word_end) == std::search(hello2, hello2_end, word, word_end)
+ );
+}
+
+template <class T, std::size_t N>
+BOOST_CXX14_CONSTEXPR bool in_namespace(const char (&ns)[N]) BOOST_NOEXCEPT {
+ BOOST_CXX14_CONSTEXPR const char* name = boost::typeindex::ctti_type_index::type_id<T>().raw_name();
+ for (std::size_t i = 0; i < N - 1; ++i)
+ if (name[i] != ns[i])
+ return false;
+
+ return true;
+}
+
+template <class T>
+BOOST_CXX14_CONSTEXPR bool is_boost_namespace() BOOST_NOEXCEPT {
+ return in_namespace<T>("boost::") || in_namespace<T>("class boost::") || in_namespace<T>("struct boost::");
+}
+
+void constexpr_test() {
+ using namespace boost::typeindex;
+
+ BOOST_CXX14_CONSTEXPR ctti_type_index t_int0 = ctti_type_index::type_id<int>();
+ (void)t_int0;
+
+ BOOST_CXX14_CONSTEXPR ctti_type_index t_short0 = ctti_type_index::type_id<short>();
+ (void)t_short0;
+
+ BOOST_CXX14_CONSTEXPR ctti_type_index t_int1 = ctti_type_index::type_id<int>();
+ (void)t_int1;
+
+ BOOST_CXX14_CONSTEXPR ctti_type_index t_short1 = ctti_type_index::type_id<short>();
+ (void)t_short1;
+
+// Following tests are known to fail on _MSC_VER == 1916.
+#if !defined(_MSC_VER) || _MSC_VER > 1916
+
+ BOOST_CXX14_CONSTEXPR bool same0 = (t_int0 == t_int1);
+ BOOST_TEST(same0);
+
+ BOOST_CXX14_CONSTEXPR bool same1 = (t_short1 == t_short0);
+ BOOST_TEST(same1);
+
+ BOOST_CXX14_CONSTEXPR bool same2 = (t_int1 == t_int1);
+ BOOST_TEST(same2);
+
+ BOOST_CXX14_CONSTEXPR bool same3 = (t_short0 == t_short0);
+ BOOST_TEST(same3);
+
+ BOOST_CXX14_CONSTEXPR bool same4 = !(t_short0 < t_short0 || t_short0 > t_short0);
+ BOOST_TEST(same4);
+
+ BOOST_CXX14_CONSTEXPR bool same5 = (t_short0 <= t_short0 && t_short0 >= t_short0);
+ BOOST_TEST(same5);
+
+
+ BOOST_CXX14_CONSTEXPR bool not_same0 = (t_int0 != t_short1);
+ BOOST_TEST(not_same0);
+
+ BOOST_CXX14_CONSTEXPR bool not_same1 = (t_int1 != t_short0);
+ BOOST_TEST(not_same1);
+
+ BOOST_CXX14_CONSTEXPR bool not_same2 = (t_int1 < t_short0 || t_int1 > t_short0);
+ BOOST_TEST(not_same2);
+
+
+ BOOST_CXX14_CONSTEXPR const char* int_name = t_int0.name();
+ BOOST_TEST(*int_name != '\0');
+
+ BOOST_CXX14_CONSTEXPR const char* short_name = t_short0.name();
+ BOOST_TEST(*short_name != '\0');
+
+ BOOST_CXX14_CONSTEXPR bool in_namespace = is_boost_namespace<ctti_type_index>();
+ BOOST_TEST(in_namespace);
+
+ BOOST_CXX14_CONSTEXPR bool not_in_namespace = !is_boost_namespace<std::string>();
+ BOOST_TEST(not_in_namespace);
+
+#endif // #if !defined(_MSC_VER) || _MSC_VER > 1916
+}
+
+
+int main() {
+ strcmp_same();
+ search_same();
+ constexpr_test();
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/type_index/test/type_index_runtime_cast_test.cpp b/src/boost/libs/type_index/test/type_index_runtime_cast_test.cpp
new file mode 100644
index 000000000..1f5344ef5
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_runtime_cast_test.cpp
@@ -0,0 +1,296 @@
+//
+// Copyright Chris Glover, 2016.
+//
+// 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 <boost/type_index/runtime_cast.hpp>
+// #include <boost/type_index/runtime_reference_cast.hpp>
+
+#include <boost/type_index/runtime_cast.hpp>
+#include <boost/type_index/runtime_cast/boost_shared_ptr_cast.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <boost/core/lightweight_test.hpp>
+
+#if !defined(BOOST_NO_CXX11_SMART_PTR)
+# include <boost/type_index/runtime_cast/std_shared_ptr_cast.hpp>
+#endif
+
+// Classes include a member variable "name" with the
+// name of the class hard coded so we can be sure that
+// the pointer offsets are all working, since we're doing
+// a cast from void* at some point.
+
+#define IMPLEMENT_CLASS(type_name) \
+ type_name() : name( #type_name ) {} \
+ std::string name;
+
+struct base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(BOOST_TYPE_INDEX_NO_BASE_CLASS)
+ IMPLEMENT_CLASS(base)
+};
+
+struct single_derived : base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(single_derived)
+};
+
+struct base1 {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(BOOST_TYPE_INDEX_NO_BASE_CLASS)
+ IMPLEMENT_CLASS(base1)
+};
+
+struct base2 {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(BOOST_TYPE_INDEX_NO_BASE_CLASS)
+ IMPLEMENT_CLASS(base2)
+};
+
+struct multiple_derived : base1, base2 {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base1)(base2))
+ IMPLEMENT_CLASS(multiple_derived)
+};
+
+struct baseV1 : virtual base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(baseV1)
+};
+
+struct baseV2 : virtual base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(baseV2)
+};
+
+struct multiple_virtual_derived : baseV1, baseV2 {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((baseV1)(baseV2))
+ IMPLEMENT_CLASS(multiple_virtual_derived)
+};
+
+struct unrelated {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(BOOST_TYPE_INDEX_NO_BASE_CLASS)
+ IMPLEMENT_CLASS(unrelated)
+};
+
+struct unrelated_with_base : base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(unrelated_with_base)
+};
+
+struct unrelatedV1 : virtual base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(unrelatedV1)
+};
+
+struct level1_a : base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(level1_a)
+};
+
+struct level1_b : base {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((base))
+ IMPLEMENT_CLASS(level1_b)
+};
+
+struct level2 : level1_a, level1_b {
+ BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST((level1_a)(level1_b))
+ IMPLEMENT_CLASS(level2)
+};
+
+struct reg_base {
+ BOOST_TYPE_INDEX_REGISTER_RUNTIME_CLASS(BOOST_TYPE_INDEX_NO_BASE_CLASS)
+};
+
+struct reg_derived : reg_base {
+ BOOST_TYPE_INDEX_REGISTER_RUNTIME_CLASS((reg_base))
+};
+
+void no_base()
+{
+ using namespace boost::typeindex;
+ base b;
+ base* b2 = runtime_pointer_cast<base>(&b);
+ BOOST_TEST_NE(b2, (base*)NULL);
+ BOOST_TEST_EQ(b2->name, "base");
+
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(&b), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<single_derived>(&b), (single_derived*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelatedV1>(&b), (unrelatedV1*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated_with_base>(&b), (unrelated_with_base*)NULL);
+}
+
+void single_base()
+{
+ using namespace boost::typeindex;
+ single_derived d;
+ base* b = &d;
+ single_derived* d2 = runtime_pointer_cast<single_derived>(b);
+ BOOST_TEST_NE(d2, (single_derived*)NULL);
+ BOOST_TEST_EQ(d2->name, "single_derived");
+
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(&d), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(b), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated_with_base>(b), (unrelated_with_base*)NULL);
+}
+
+void multiple_base()
+{
+ using namespace boost::typeindex;
+ multiple_derived d;
+ base1* b1 = &d;
+ multiple_derived* d2 = runtime_pointer_cast<multiple_derived>(b1);
+ BOOST_TEST_NE(d2, (multiple_derived*)NULL);
+ BOOST_TEST_EQ(d2->name, "multiple_derived");
+
+ base2* b2 = runtime_pointer_cast<base2>(b1);
+ BOOST_TEST_NE(b2, (base2*)NULL);
+ BOOST_TEST_EQ(b2->name, "base2");
+
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(&d), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(b1), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated_with_base>(b1), (unrelated_with_base*)NULL);
+}
+
+void virtual_base()
+{
+ using namespace boost::typeindex;
+ multiple_virtual_derived d;
+ base* b = &d;
+ multiple_virtual_derived* d2 = runtime_pointer_cast<multiple_virtual_derived>(b);
+ baseV1* bv1 = runtime_pointer_cast<baseV1>(b);
+ baseV2* bv2 = runtime_pointer_cast<baseV2>(b);
+
+ BOOST_TEST_NE(d2, (multiple_virtual_derived*)NULL);
+ BOOST_TEST_EQ(d2->name, "multiple_virtual_derived");
+
+ BOOST_TEST_NE(bv1, (baseV1*)NULL);
+ BOOST_TEST_EQ(bv1->name, "baseV1");
+
+ BOOST_TEST_NE(bv2, (baseV2*)NULL);
+ BOOST_TEST_EQ(bv2->name, "baseV2");
+
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(b), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(&d), (unrelated*)NULL);
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated_with_base>(b), (unrelated_with_base*)NULL);
+}
+
+void pointer_interface()
+{
+ using namespace boost::typeindex;
+ single_derived d;
+ base* b = &d;
+ single_derived* d2 = runtime_cast<single_derived*>(b);
+ BOOST_TEST_NE(d2, (single_derived*)NULL);
+ BOOST_TEST_EQ(d2->name, "single_derived");
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(b), (unrelated*)NULL);
+}
+
+void reference_interface()
+{
+ using namespace boost::typeindex;
+ single_derived d;
+ base& b = d;
+ single_derived& d2 = runtime_cast<single_derived&>(b);
+ BOOST_TEST_EQ(d2.name, "single_derived");
+
+ try {
+ unrelated& u = runtime_cast<unrelated&>(b);
+ (void)u;
+ BOOST_TEST(!"should throw bad_runtime_cast");
+ }
+ catch(boost::typeindex::bad_runtime_cast&) {
+ }
+ catch(...) {
+ BOOST_TEST(!"should throw bad_runtime_cast");
+ }
+}
+
+void const_pointer_interface()
+{
+ using namespace boost::typeindex;
+ const single_derived d;
+ base const* b = &d;
+ single_derived const* d2 = runtime_cast<single_derived const*>(b);
+ BOOST_TEST_NE(d2, (single_derived*)NULL);
+ BOOST_TEST_EQ(d2->name, "single_derived");
+ BOOST_TEST_EQ(runtime_pointer_cast<unrelated>(b), (unrelated*)NULL);
+}
+
+void const_reference_interface()
+{
+ using namespace boost::typeindex;
+ const single_derived d;
+ base const& b = d;
+ single_derived const& d2 = runtime_cast<single_derived const&>(b);
+ BOOST_TEST_EQ(d2.name, "single_derived");
+
+ try {
+ unrelated const& u = runtime_cast<unrelated const&>(b);
+ (void)u;
+ BOOST_TEST(!"should throw bad_runtime_cast");
+ }
+ catch(boost::typeindex::bad_runtime_cast&) {
+ }
+ catch(...) {
+ BOOST_TEST(!"should throw bad_runtime_cast");
+ }
+}
+
+void diamond_non_virtual()
+{
+ using namespace boost::typeindex;
+ level2 inst;
+ level1_a* l1a = &inst;
+ base* b1 = l1a;
+ level1_b* l1_b = runtime_cast<level1_b*>(b1);
+ BOOST_TEST_NE(l1_b, (level1_b*)NULL);
+ BOOST_TEST_EQ(l1_b->name, "level1_b");
+}
+
+void boost_shared_ptr()
+{
+ using namespace boost::typeindex;
+ boost::shared_ptr<single_derived> d = boost::make_shared<single_derived>();
+ boost::shared_ptr<base> b = d;
+ boost::shared_ptr<single_derived> d2 = runtime_pointer_cast<single_derived>(b);
+ BOOST_TEST_NE(d2, boost::shared_ptr<single_derived>());
+ BOOST_TEST_EQ(d2->name, "single_derived");
+}
+
+void std_shared_ptr()
+{
+#if !defined(BOOST_NO_CXX11_SMART_PTR)
+ using namespace boost::typeindex;
+ std::shared_ptr<single_derived> d = std::make_shared<single_derived>();
+ std::shared_ptr<base> b = d;
+ std::shared_ptr<single_derived> d2 = runtime_pointer_cast<single_derived>(b);
+ BOOST_TEST_NE(d2, std::shared_ptr<single_derived>());
+ BOOST_TEST_EQ(d2->name, "single_derived");
+#endif
+}
+
+void register_runtime_class()
+{
+ using namespace boost::typeindex;
+ reg_derived rd;
+ reg_base* rb = &rd;
+ reg_derived* prd = runtime_pointer_cast<reg_derived>(rb);
+ BOOST_TEST_NE(prd, (reg_derived*)NULL);
+ BOOST_TEST_EQ(type_id_runtime(*prd), type_id<reg_derived>());
+}
+
+int main() {
+ no_base();
+ single_derived();
+ multiple_base();
+ virtual_base();
+ pointer_interface();
+ reference_interface();
+ const_pointer_interface();
+ const_reference_interface();
+ diamond_non_virtual();
+ boost_shared_ptr();
+ std_shared_ptr();
+ register_runtime_class();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/type_index/test/type_index_test.cpp b/src/boost/libs/type_index/test/type_index_test.cpp
new file mode 100644
index 000000000..9a4c73c5a
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_test.cpp
@@ -0,0 +1,400 @@
+//
+// Copyright 2012-2020 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 <boost/type_index.hpp>
+
+#include <boost/lexical_cast.hpp>
+
+#include <boost/core/lightweight_test.hpp>
+
+namespace my_namespace1 {
+ class my_class{};
+}
+
+
+namespace my_namespace2 {
+ class my_class{};
+}
+
+
+void names_matches_type_id()
+{
+ using namespace boost::typeindex;
+ BOOST_TEST_EQ(type_id<int>().pretty_name(), "int");
+ BOOST_TEST_EQ(type_id<double>().pretty_name(), "double");
+
+ BOOST_TEST_EQ(type_id<int>().name(), type_id<int>().name());
+ BOOST_TEST_NE(type_id<int>().name(), type_id<double>().name());
+ BOOST_TEST_NE(type_id<double>().name(), type_id<int>().name());
+ BOOST_TEST_EQ(type_id<double>().name(), type_id<double>().name());
+}
+
+void default_construction()
+{
+ using namespace boost::typeindex;
+ type_index ti1, ti2;
+ BOOST_TEST_EQ(ti1, ti2);
+ BOOST_TEST_EQ(type_id<void>(), ti1);
+
+ BOOST_TEST_EQ(type_id<void>().name(), ti1.name());
+ BOOST_TEST_NE(type_id<int>(), ti1);
+}
+
+
+void copy_construction()
+{
+ using namespace boost::typeindex;
+ type_index ti1, ti2 = type_id<int>();
+ BOOST_TEST_NE(ti1, ti2);
+ ti1 = ti2;
+ BOOST_TEST_EQ(ti2, ti1);
+
+ const type_index ti3(ti1);
+ BOOST_TEST_EQ(ti3, ti1);
+}
+
+void comparators_type_id()
+{
+ using namespace boost::typeindex;
+ type_index t_int = type_id<int>();
+ type_index t_double = type_id<double>();
+
+ BOOST_TEST_EQ(t_int, t_int);
+ BOOST_TEST_LE(t_int, t_int);
+ BOOST_TEST_GE(t_int, t_int);
+ BOOST_TEST_NE(t_int, t_double);
+
+ BOOST_TEST_LE(t_double, t_double);
+ BOOST_TEST_GE(t_double, t_double);
+ BOOST_TEST_NE(t_double, t_int);
+
+ BOOST_TEST(t_double < t_int || t_int < t_double);
+ BOOST_TEST(t_double > t_int || t_int > t_double);
+}
+
+void hash_code_type_id()
+{
+ using namespace boost::typeindex;
+ std::size_t t_int1 = type_id<int>().hash_code();
+ std::size_t t_double1 = type_id<double>().hash_code();
+
+ std::size_t t_int2 = type_id<int>().hash_code();
+ std::size_t t_double2 = type_id<double>().hash_code();
+
+ BOOST_TEST_EQ(t_int1, t_int2);
+ BOOST_TEST_NE(t_int1, t_double2);
+ BOOST_TEST_LE(t_double1, t_double2);
+}
+
+
+
+template <class T1, class T2>
+static void test_with_modofiers() {
+ using namespace boost::typeindex;
+
+ type_index t1 = type_id_with_cvr<T1>();
+ type_index t2 = type_id_with_cvr<T2>();
+
+ BOOST_TEST_NE(t2, t1);
+ BOOST_TEST(t2 != t1.type_info());
+ BOOST_TEST(t2.type_info() != t1);
+
+ BOOST_TEST(t1 < t2 || t2 < t1);
+ BOOST_TEST(t1 > t2 || t2 > t1);
+ BOOST_TEST(t1.type_info() < t2 || t2.type_info() < t1);
+ BOOST_TEST(t1.type_info() > t2 || t2.type_info() > t1);
+ BOOST_TEST(t1 < t2.type_info() || t2 < t1.type_info());
+ BOOST_TEST(t1 > t2.type_info() || t2 > t1.type_info());
+
+ // Chaecking that comparison operators overloads compile
+ BOOST_TEST(t1 <= t2 || t2 <= t1);
+ BOOST_TEST(t1 >= t2 || t2 >= t1);
+ BOOST_TEST(t1.type_info() <= t2 || t2.type_info() <= t1);
+ BOOST_TEST(t1.type_info() >= t2 || t2.type_info() >= t1);
+ BOOST_TEST(t1 <= t2.type_info() || t2 <= t1.type_info());
+ BOOST_TEST(t1 >= t2.type_info() || t2 >= t1.type_info());
+
+ BOOST_TEST_EQ(t1, type_id_with_cvr<T1>());
+ BOOST_TEST_EQ(t2, type_id_with_cvr<T2>());
+ BOOST_TEST(t1 == type_id_with_cvr<T1>().type_info());
+ BOOST_TEST(t2 == type_id_with_cvr<T2>().type_info());
+ BOOST_TEST(t1.type_info() == type_id_with_cvr<T1>());
+ BOOST_TEST(t2.type_info() == type_id_with_cvr<T2>());
+
+ BOOST_TEST_EQ(t1.hash_code(), type_id_with_cvr<T1>().hash_code());
+ BOOST_TEST_EQ(t2.hash_code(), type_id_with_cvr<T2>().hash_code());
+
+ BOOST_TEST_NE(t1.hash_code(), type_id_with_cvr<T2>().hash_code());
+ BOOST_TEST_NE(t2.hash_code(), type_id_with_cvr<T1>().hash_code());
+}
+
+void type_id_storing_modifiers()
+{
+ test_with_modofiers<int, const int>();
+ test_with_modofiers<int, const int&>();
+ test_with_modofiers<int, int&>();
+ test_with_modofiers<int, volatile int>();
+ test_with_modofiers<int, volatile int&>();
+ test_with_modofiers<int, const volatile int>();
+ test_with_modofiers<int, const volatile int&>();
+
+ test_with_modofiers<const int, int>();
+ test_with_modofiers<const int, const int&>();
+ test_with_modofiers<const int, int&>();
+ test_with_modofiers<const int, volatile int>();
+ test_with_modofiers<const int, volatile int&>();
+ test_with_modofiers<const int, const volatile int>();
+ test_with_modofiers<const int, const volatile int&>();
+
+ test_with_modofiers<const int&, int>();
+ test_with_modofiers<const int&, const int>();
+ test_with_modofiers<const int&, int&>();
+ test_with_modofiers<const int&, volatile int>();
+ test_with_modofiers<const int&, volatile int&>();
+ test_with_modofiers<const int&, const volatile int>();
+ test_with_modofiers<const int&, const volatile int&>();
+
+ test_with_modofiers<int&, const int>();
+ test_with_modofiers<int&, const int&>();
+ test_with_modofiers<int&, int>();
+ test_with_modofiers<int&, volatile int>();
+ test_with_modofiers<int&, volatile int&>();
+ test_with_modofiers<int&, const volatile int>();
+ test_with_modofiers<int&, const volatile int&>();
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ test_with_modofiers<int&&, const int>();
+ test_with_modofiers<int&&, const int&>();
+ test_with_modofiers<int&&, const int&&>();
+ test_with_modofiers<int&&, int>();
+ test_with_modofiers<int&&, volatile int>();
+ test_with_modofiers<int&&, volatile int&>();
+ test_with_modofiers<int&&, volatile int&&>();
+ test_with_modofiers<int&&, const volatile int>();
+ test_with_modofiers<int&&, const volatile int&>();
+ test_with_modofiers<int&&, const volatile int&&>();
+#endif
+}
+
+template <class T>
+static void test_storing_nonstoring_modifiers_templ() {
+ using namespace boost::typeindex;
+
+ type_index t1 = type_id_with_cvr<T>();
+ type_index t2 = type_id<T>();
+
+ BOOST_TEST_EQ(t2, t1);
+ BOOST_TEST_EQ(t1, t2);
+ BOOST_TEST(t1 <= t2);
+ BOOST_TEST(t1 >= t2);
+ BOOST_TEST(t2 <= t1);
+ BOOST_TEST(t2 >= t1);
+
+ BOOST_TEST_EQ(t2.pretty_name(), t1.pretty_name());
+}
+
+void type_id_storing_modifiers_vs_nonstoring()
+{
+ test_storing_nonstoring_modifiers_templ<int>();
+ test_storing_nonstoring_modifiers_templ<my_namespace1::my_class>();
+ test_storing_nonstoring_modifiers_templ<my_namespace2::my_class>();
+
+ boost::typeindex::type_index t1 = boost::typeindex::type_id_with_cvr<const int>();
+ boost::typeindex::type_index t2 = boost::typeindex::type_id<int>();
+ BOOST_TEST_NE(t2, t1);
+ BOOST_TEST(t1.pretty_name() == "const int" || t1.pretty_name() == "int const");
+}
+
+void type_index_stream_operator_via_lexical_cast_testing()
+{
+ using namespace boost::typeindex;
+
+ std::string s_int2 = boost::lexical_cast<std::string>(type_id<int>());
+ BOOST_TEST_EQ(s_int2, "int");
+
+ std::string s_double2 = boost::lexical_cast<std::string>(type_id<double>());
+ BOOST_TEST_EQ(s_double2, "double");
+}
+
+void type_index_stripping_cvr_test()
+{
+ using namespace boost::typeindex;
+
+ BOOST_TEST_EQ(type_id<int>(), type_id<const int>());
+ BOOST_TEST_EQ(type_id<int>(), type_id<const volatile int>());
+ BOOST_TEST_EQ(type_id<int>(), type_id<const volatile int&>());
+
+ BOOST_TEST_EQ(type_id<int>(), type_id<int&>());
+ BOOST_TEST_EQ(type_id<int>(), type_id<volatile int>());
+ BOOST_TEST_EQ(type_id<int>(), type_id<volatile int&>());
+
+
+ BOOST_TEST_EQ(type_id<double>(), type_id<const double>());
+ BOOST_TEST_EQ(type_id<double>(), type_id<const volatile double>());
+ BOOST_TEST_EQ(type_id<double>(), type_id<const volatile double&>());
+
+ BOOST_TEST_EQ(type_id<double>(), type_id<double&>());
+ BOOST_TEST_EQ(type_id<double>(), type_id<volatile double>());
+ BOOST_TEST_EQ(type_id<double>(), type_id<volatile double&>());
+}
+
+
+void type_index_user_defined_class_test()
+{
+ using namespace boost::typeindex;
+
+ BOOST_TEST_EQ(type_id<my_namespace1::my_class>(), type_id<my_namespace1::my_class>());
+ BOOST_TEST_EQ(type_id<my_namespace2::my_class>(), type_id<my_namespace2::my_class>());
+
+#ifndef BOOST_NO_RTTI
+ BOOST_TEST(type_id<my_namespace1::my_class>() == typeid(my_namespace1::my_class));
+ BOOST_TEST(type_id<my_namespace2::my_class>() == typeid(my_namespace2::my_class));
+ BOOST_TEST(typeid(my_namespace1::my_class) == type_id<my_namespace1::my_class>());
+ BOOST_TEST(typeid(my_namespace2::my_class) == type_id<my_namespace2::my_class>());
+#endif
+
+ BOOST_TEST_NE(type_id<my_namespace1::my_class>(), type_id<my_namespace2::my_class>());
+ BOOST_TEST_NE(
+ type_id<my_namespace1::my_class>().pretty_name().find("my_namespace1::my_class"),
+ std::string::npos);
+}
+
+
+
+
+
+struct A {
+public:
+ BOOST_TYPE_INDEX_REGISTER_CLASS
+ virtual ~A(){}
+};
+
+struct B: public A {
+ BOOST_TYPE_INDEX_REGISTER_CLASS
+};
+
+struct C: public B {
+ BOOST_TYPE_INDEX_REGISTER_CLASS
+};
+
+void comparators_type_id_runtime()
+{
+ C c1;
+ B b1;
+ A* pc1 = &c1;
+ A& rc1 = c1;
+ A* pb1 = &b1;
+ A& rb1 = b1;
+
+#ifndef BOOST_NO_RTTI
+ BOOST_TEST(typeid(rc1) == typeid(*pc1));
+ BOOST_TEST(typeid(rb1) == typeid(*pb1));
+
+ BOOST_TEST(typeid(rc1) != typeid(*pb1));
+ BOOST_TEST(typeid(rb1) != typeid(*pc1));
+
+ BOOST_TEST(typeid(&rc1) == typeid(pb1));
+ BOOST_TEST(typeid(&rb1) == typeid(pc1));
+#else
+ BOOST_TEST(boost::typeindex::type_index(pc1->boost_type_index_type_id_runtime_()).raw_name());
+#endif
+
+ BOOST_TEST_EQ(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pc1));
+ BOOST_TEST_EQ(boost::typeindex::type_id<C>(), boost::typeindex::type_id_runtime(*pc1));
+ BOOST_TEST_EQ(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pb1));
+ BOOST_TEST_EQ(boost::typeindex::type_id<B>(), boost::typeindex::type_id_runtime(*pb1));
+
+ BOOST_TEST_NE(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pb1));
+ BOOST_TEST_NE(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pc1));
+
+#ifndef BOOST_NO_RTTI
+ BOOST_TEST_EQ(boost::typeindex::type_id_runtime(&rc1), boost::typeindex::type_id_runtime(pb1));
+ BOOST_TEST_EQ(boost::typeindex::type_id_runtime(&rb1), boost::typeindex::type_id_runtime(pc1));
+
+ BOOST_TEST(boost::typeindex::type_id_runtime(rc1) == typeid(*pc1));
+ BOOST_TEST(boost::typeindex::type_id_runtime(rb1) == typeid(*pb1));
+
+ BOOST_TEST(boost::typeindex::type_id_runtime(rc1) != typeid(*pb1));
+ BOOST_TEST(boost::typeindex::type_id_runtime(rb1) != typeid(*pc1));
+ BOOST_TEST(boost::typeindex::type_id_runtime(&rc1) == typeid(pb1));
+ BOOST_TEST(boost::typeindex::type_id_runtime(&rb1) == typeid(pc1));
+#endif
+}
+
+
+#ifndef BOOST_NO_RTTI
+
+void comparators_type_id_vs_type_info()
+{
+ using namespace boost::typeindex;
+ type_index t_int = type_id<int>();
+
+ BOOST_TEST(t_int == typeid(int));
+ BOOST_TEST(typeid(int) == t_int);
+ BOOST_TEST(t_int <= typeid(int));
+ BOOST_TEST(typeid(int) <= t_int);
+ BOOST_TEST(t_int >= typeid(int));
+ BOOST_TEST(typeid(int) >= t_int);
+
+ type_index t_double = type_id<double>();
+
+ BOOST_TEST(t_double == typeid(double));
+ BOOST_TEST(typeid(double) == t_double);
+ BOOST_TEST(t_double <= typeid(double));
+ BOOST_TEST(typeid(double) <= t_double);
+ BOOST_TEST(t_double >= typeid(double));
+ BOOST_TEST(typeid(double) >= t_double);
+
+ if (t_double < t_int) {
+ BOOST_TEST(t_double < typeid(int));
+ BOOST_TEST(typeid(double) < t_int);
+ BOOST_TEST(typeid(int) > t_double);
+ BOOST_TEST(t_int > typeid(double));
+
+
+ BOOST_TEST(t_double <= typeid(int));
+ BOOST_TEST(typeid(double) <= t_int);
+ BOOST_TEST(typeid(int) >= t_double);
+ BOOST_TEST(t_int >= typeid(double));
+ } else {
+ BOOST_TEST(t_double > typeid(int));
+ BOOST_TEST(typeid(double) > t_int);
+ BOOST_TEST(typeid(int) < t_double);
+ BOOST_TEST(t_int < typeid(double));
+
+
+ BOOST_TEST(t_double >= typeid(int));
+ BOOST_TEST(typeid(double) >= t_int);
+ BOOST_TEST(typeid(int) <= t_double);
+ BOOST_TEST(t_int <= typeid(double));
+ }
+
+}
+
+#endif // BOOST_NO_RTTI
+
+int main() {
+ names_matches_type_id();
+ default_construction();
+ copy_construction();
+ comparators_type_id();
+ hash_code_type_id();
+
+ type_id_storing_modifiers();
+ type_id_storing_modifiers_vs_nonstoring();
+ type_index_stream_operator_via_lexical_cast_testing();
+ type_index_stripping_cvr_test();
+ type_index_user_defined_class_test();
+
+ comparators_type_id_runtime();
+#ifndef BOOST_NO_RTTI
+ comparators_type_id_vs_type_info();
+#endif
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/type_index/test/type_index_test_ctti_alignment.cpp b/src/boost/libs/type_index/test/type_index_test_ctti_alignment.cpp
new file mode 100644
index 000000000..95b25d718
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_test_ctti_alignment.cpp
@@ -0,0 +1,18 @@
+//
+// Copyright 2012-2020 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 <boost/type_index/ctti_type_index.hpp>
+#include <boost/type_traits/alignment_of.hpp>
+
+int main() {
+ BOOST_STATIC_ASSERT_MSG(
+ boost::alignment_of<boost::typeindex::detail::ctti_data>::value == boost::alignment_of<char>::value,
+ "Alignments of boost::typeindex::detail::ctti_data and char differ. "
+ "It is unsafe to reinterpret_cast between them."
+ );
+}
+
diff --git a/src/boost/libs/type_index/test/type_index_test_ctti_construct_fail.cpp b/src/boost/libs/type_index/test/type_index_test_ctti_construct_fail.cpp
new file mode 100644
index 000000000..ce3c3a890
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_test_ctti_construct_fail.cpp
@@ -0,0 +1,15 @@
+//
+// Copyright 2012-2020 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 <boost/type_index/ctti_type_index.hpp>
+
+int main() {
+ using namespace boost::typeindex;
+ ctti_type_index::type_info_t t;
+ (void)t;
+}
+
diff --git a/src/boost/libs/type_index/test/type_index_test_ctti_copy_fail.cpp b/src/boost/libs/type_index/test/type_index_test_ctti_copy_fail.cpp
new file mode 100644
index 000000000..fad7fa487
--- /dev/null
+++ b/src/boost/libs/type_index/test/type_index_test_ctti_copy_fail.cpp
@@ -0,0 +1,15 @@
+//
+// Copyright 2012-2020 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 <boost/type_index/ctti_type_index.hpp>
+
+int main() {
+ using namespace boost::typeindex;
+ ctti_type_index::type_info_t t = ctti_type_index::type_id<int>().type_info();
+ (void)t;
+}
+