Add DISALLOW_COPY_AND_ASSIGN macro.
Make the DISALLOW_COPY_AND_ASSIGN macro delete the member functions rather
than just not defining them to improve analysis of the Scoped.. classes.
Add a few missing const qualifiers.
Change-Id: I48eee0c22908d45a05df6979aa61442d2eedcf36
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index cfab8f7..bf01986 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -172,6 +172,20 @@
jniLogException(&env->functions, priority, tag, exception);
}
+#if !defined(DISALLOW_COPY_AND_ASSIGN)
+// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. It goes in the private:
+// declarations in a class.
+#if __cplusplus >= 201103L
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&) = delete; \
+ void operator=(const TypeName&) = delete
+#else
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+#endif // __has_feature(cxx_deleted_functions)
+#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
+
#endif
/*