Index: base/mac/foundation_util.h |
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h |
index ee23a17fb16e6c0c5c6856c6cd0ccbd9dd43c120..6505e614ed56b2120a23d8318126a90bc063112f 100644 |
--- a/base/mac/foundation_util.h |
+++ b/base/mac/foundation_util.h |
@@ -272,14 +272,16 @@ template<typename T> |
T CFCast(const CFTypeRef& cf_val); |
template<typename T> |
-T CFCastStrict(const CFTypeRef& cf_val); |
+T CFCastStrict(const CFTypeRef& cf_val) { |
+ DCHECK(!cf_val || CFCast<T>(cf_val)); |
+ // Note: CFTypeRef is const void*, but CGColorRef and some others are non- |
+ // const. So this may also cast away a const qualifier. |
+ return (T)(cf_val); |
+} |
#define CF_CAST_DECL(TypeCF) \ |
template<> BASE_EXPORT TypeCF##Ref \ |
-CFCast<TypeCF##Ref>(const CFTypeRef& cf_val);\ |
-\ |
-template<> BASE_EXPORT TypeCF##Ref \ |
-CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val); |
+CFCast<TypeCF##Ref>(const CFTypeRef& cf_val); |
CF_CAST_DECL(CFArray); |
CF_CAST_DECL(CFBag); |
@@ -339,9 +341,8 @@ T* ObjCCast(id objc_val) { |
template<typename T> |
T* ObjCCastStrict(id objc_val) { |
- T* rv = ObjCCast<T>(objc_val); |
- DCHECK(objc_val == nil || rv); |
- return rv; |
+ DCHECK(!objc_val || ObjCCast<T>(objc_val)); |
+ return reinterpret_cast<T*>(objc_val); |
} |
#endif // defined(__OBJC__) |