aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-11-09 05:55:03 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-11-09 05:55:03 +0000
commit3481cdc57382b315c96ad82a6e166f9914dadddb (patch)
treeb9502ae1df0bdf5e31046c3471d6e4412c304a89
parentc197a3ab4d1498198bc190216bce41ee3887ad3a (diff)
downloadexternal_llvm-3481cdc57382b315c96ad82a6e166f9914dadddb.zip
external_llvm-3481cdc57382b315c96ad82a6e166f9914dadddb.tar.gz
external_llvm-3481cdc57382b315c96ad82a6e166f9914dadddb.tar.bz2
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
-rw-r--r--include/llvm/ADT/polymorphic_ptr.h2
-rw-r--r--unittests/ADT/polymorphic_ptr_test.cpp5
2 files changed, 6 insertions, 1 deletions
diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h
index 6114b65..a168747 100644
--- a/include/llvm/ADT/polymorphic_ptr.h
+++ b/include/llvm/ADT/polymorphic_ptr.h
@@ -38,7 +38,7 @@ template <typename T> 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 d9a2c3f..fbe60df 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<polymorphic_ptr<Base> >(new DerivedA());
+ EXPECT_NE(a, copy);
+ EXPECT_EQ("DerivedA", copy->name());
}
}