diff options
Diffstat (limited to 'test/std/language.support/support.rtti/type.info/type_info.pass.cpp')
-rw-r--r-- | test/std/language.support/support.rtti/type.info/type_info.pass.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/std/language.support/support.rtti/type.info/type_info.pass.cpp b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp index 2616865e6da9..74c1c0c7df99 100644 --- a/test/std/language.support/support.rtti/type.info/type_info.pass.cpp +++ b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp @@ -10,11 +10,16 @@ // test type_info #include <typeinfo> +#include <string> #include <cstring> #include <cassert> +bool test_constructor_explicit(std::type_info const&) { return false; } +bool test_constructor_explicit(std::string const&) { return true; } + int main() { + { const std::type_info& t1 = typeid(int); const std::type_info& t2 = typeid(int); assert(t1 == t2); @@ -23,4 +28,13 @@ int main() assert(!t1.before(t2)); assert(strcmp(t1.name(), t2.name()) == 0); assert(strcmp(t1.name(), t3.name()) != 0); + } + { + // type_info has a protected constructor taking a string literal. This + // constructor is not intended for users. However it still participates + // in overload resolution, so we need to ensure that it is marked explicit + // to avoid ambiguous conversions. + // See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216201 + assert(test_constructor_explicit("abc")); + } } |