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

Unified Diff: base/mac/scoped_typeref.h

Issue 2028823003: Mac: Make ScopedTypeRef require explicit constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dependency Created 4 years, 6 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 | chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/scoped_typeref.h
diff --git a/base/mac/scoped_typeref.h b/base/mac/scoped_typeref.h
index eed5afb539e35ce7b6a25a4f56daa87291b92e4b..11767186455e0aa859d0a7b9705372f472e868e2 100644
--- a/base/mac/scoped_typeref.h
+++ b/base/mac/scoped_typeref.h
@@ -53,7 +53,7 @@ class ScopedTypeRef {
public:
typedef T element_type;
- ScopedTypeRef(
+ explicit ScopedTypeRef(
T object = Traits::InvalidValue(),
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
: object_(object) {
@@ -67,12 +67,10 @@ class ScopedTypeRef {
object_ = Traits::Retain(object_);
}
- // Without this, passing a ScopedTypeRef<A,TraitsX> to construct a
- // ScopedTypeRef<A,TraitsY> would automatically cast down to an A, and then
- // ASSUME ownership of A, when a retain is what was needed.
- template<typename OtherTraits>
- ScopedTypeRef(const ScopedTypeRef<T, OtherTraits>& that_with_other_traits)
- : object_(that_with_other_traits.get()) {
+ // This allows passing an object to a function that takes its superclass.
+ template <typename R, typename RTraits>
+ explicit ScopedTypeRef(const ScopedTypeRef<R, RTraits>& that_as_subclass)
+ : object_(that_as_subclass.get()) {
if (object_)
object_ = Traits::Retain(object_);
}
« no previous file with comments | « no previous file | chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698