Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: base/memory/ref_counted.h

Issue 1904603002: Fix scoped_refptr copy/move-conversion overload resolution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dummy type name Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698