From 3481cdc57382b315c96ad82a6e166f9914dadddb Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 9 Nov 2013 05:55:03 +0000 Subject: [PATCH] Switch to allow implicit construction. In many cases, we're wrapping a derived type and this makes it *much* easier to write this code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194321 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/polymorphic_ptr.h | 2 +- unittests/ADT/polymorphic_ptr_test.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h index 6114b65a309..a1687474ef4 100644 --- a/include/llvm/ADT/polymorphic_ptr.h +++ b/include/llvm/ADT/polymorphic_ptr.h @@ -38,7 +38,7 @@ template class polymorphic_ptr { T *ptr; public: - explicit polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} + polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg->clone()) {} #if LLVM_HAS_RVALUE_REFERENCES polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {} diff --git a/unittests/ADT/polymorphic_ptr_test.cpp b/unittests/ADT/polymorphic_ptr_test.cpp index d9a2c3fdd11..fbe60df523c 100644 --- a/unittests/ADT/polymorphic_ptr_test.cpp +++ b/unittests/ADT/polymorphic_ptr_test.cpp @@ -113,6 +113,11 @@ TEST(polymorphic_ptr_test, Polymorphism) { copy = dummy_copy(b); EXPECT_NE(b, copy); EXPECT_EQ("DerivedB", copy->name()); + + // Test creating a copy out of a temporary directly. + copy = dummy_copy >(new DerivedA()); + EXPECT_NE(a, copy); + EXPECT_EQ("DerivedA", copy->name()); } }