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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
index b6f6e3754604f9ae23cb9892a0573661d14a55ef..2f192d8b2e3e1f9bd877951f0779ddd4ac897634 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
@@ -18,10 +18,19 @@ class {{union.name}} {
{{union.name}}();
~{{union.name}}();
-{% if union|is_cloneable_kind %}
+ // Clone() is a template so it is only instantiated if it is used. Thus, the
+ // bindings generator does not need to know whether Clone() or copy
+ // constructor/assignment are available for members.
+ template <typename UnionPtrType = {{union.name}}Ptr>
{{union.name}}Ptr Clone() const;
-{%- endif %}
- bool Equals(const {{union.name}}& other) const;
+
+ // Equals() is a template so it is only instantiated if it is used. Thus, the
+ // bindings generator does not need to know whether Equals() or == operator
+ // are available for members.
+ template <typename T,
+ typename std::enable_if<std::is_same<
+ T, {{union.name}}>::value>::type* = nullptr>
+ bool Equals(const T& other) const;
Tag which() const {
return tag_;

Powered by Google App Engine
This is Rietveld 408576698