Index: base/memory/ref_counted.h |
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
index e73951481be0e5501ae2bdc73c56502d3d51d7b9..0c0e0afd770f4bb3f71d222b098d200c4e3688d4 100644 |
--- a/base/memory/ref_counted.h |
+++ b/base/memory/ref_counted.h |
@@ -7,6 +7,7 @@ |
#include <cassert> |
#include <iosfwd> |
+#include <type_traits> |
#include "base/atomic_ref_count.h" |
#include "base/base_export.h" |
@@ -283,7 +284,9 @@ class scoped_refptr { |
} |
// Copy conversion constructor. |
- template <typename U> |
+ template <typename U, |
+ typename = typename std::enable_if< |
+ std::is_convertible<U*, T*>::value>::type> |
scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) { |
if (ptr_) |
AddRef(ptr_); |
@@ -294,7 +297,9 @@ class scoped_refptr { |
scoped_refptr(scoped_refptr&& r) : ptr_(r.get()) { r.ptr_ = nullptr; } |
// Move conversion constructor. |
- template <typename U> |
+ template <typename U, |
+ typename = typename std::enable_if< |
+ std::is_convertible<U*, T*>::value>::type> |
scoped_refptr(scoped_refptr<U>&& r) : ptr_(r.get()) { |
r.ptr_ = nullptr; |
} |