From 33d9e4d0e61cda8ced97fbb6d469c81bed0eaf36 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 28 Apr 2023 14:24:31 -0700 Subject: [PATCH 1/3] Export global type_info. --- stl/inc/typeinfo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stl/inc/typeinfo b/stl/inc/typeinfo index e1e50f05eb8..bb0ea60442b 100644 --- a/stl/inc/typeinfo +++ b/stl/inc/typeinfo @@ -22,6 +22,10 @@ _STL_DISABLE_CLANG_WARNINGS #include +extern "C++" { // attach declarations to the global module, see N4944 [module.unit]/7 +_EXPORT_STD class type_info; // for typeid, MSVC looks for type_info in the global namespace +} // extern "C++" + _STD_BEGIN // size in pointers of std::function and std::any (roughly 3 pointers larger than std::string when building debug) From 438ea797fee946b99dfce065ae337b099fe79b27 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 28 Apr 2023 14:37:11 -0700 Subject: [PATCH 2/3] Test `typeid(T).name()`. --- tests/std/include/test_header_units_and_modules.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index 33fc4115a77..ce362844dc7 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -937,6 +937,8 @@ void test_typeinfo() { const type_info& t3 = typeid(double); assert(t1 == t2); assert(t1 != t3); + + assert(typeid(double).name() == "double"sv); // also test DevCom-10349749 } void test_unordered_map() { From 3d3e09c660408873da11c1faa83ec66dacfa6e02 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 28 Apr 2023 14:45:50 -0700 Subject: [PATCH 3/3] We usually mention `extern "C++"` in-line here. --- stl/inc/typeinfo | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stl/inc/typeinfo b/stl/inc/typeinfo index bb0ea60442b..f404bdd60bf 100644 --- a/stl/inc/typeinfo +++ b/stl/inc/typeinfo @@ -22,9 +22,7 @@ _STL_DISABLE_CLANG_WARNINGS #include -extern "C++" { // attach declarations to the global module, see N4944 [module.unit]/7 -_EXPORT_STD class type_info; // for typeid, MSVC looks for type_info in the global namespace -} // extern "C++" +_EXPORT_STD extern "C++" class type_info; // for typeid, MSVC looks for type_info in the global namespace _STD_BEGIN