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

Unified Diff: base/android/scoped_java_ref.h

Issue 1340683002: Remove base's implicit_cast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implicitcast: numericstest Created 5 years, 3 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 | « android_webview/native/aw_contents.cc ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/scoped_java_ref.h
diff --git a/base/android/scoped_java_ref.h b/base/android/scoped_java_ref.h
index 6d441954a4e902f0781a9f1bc54cd5a7bafeb87e..cad63b75617a106c39b26fc02eed16c8293f804d 100644
--- a/base/android/scoped_java_ref.h
+++ b/base/android/scoped_java_ref.h
@@ -11,6 +11,7 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/template_util.h"
namespace base {
namespace android {
@@ -178,7 +179,8 @@ class ScopedJavaLocalRef : public JavaRef<T> {
template<typename U>
void Reset(JNIEnv* env, U obj) {
- implicit_cast<T>(obj); // Ensure U is assignable to T
+ static_assert(base::is_convertible<U, T>::value,
+ "U must be convertible to T");
env_ = this->SetNewLocalRef(env, obj);
}
@@ -242,7 +244,8 @@ class ScopedJavaGlobalRef : public JavaRef<T> {
template<typename U>
void Reset(JNIEnv* env, U obj) {
- implicit_cast<T>(obj); // Ensure U is assignable to T
+ static_assert(base::is_convertible<U, T>::value,
+ "U must be convertible to T");
this->SetNewGlobalRef(env, obj);
}
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698