Fix type_info's constructor by making it explicit again.
In recent changes type_info's private constructor was accidentally made implicit. This patch fixes that. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292294 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user