diff options
author | Anqi Dong <anqid@google.com> | 2022-11-09 06:22:02 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-09 06:22:02 +0000 |
commit | 5bac2a9fc964d4022f2009af5bd2806f9e7c2762 (patch) | |
tree | fb00cf067d8f86087025eae650026633fe515b73 /pw_protobuf | |
parent | de551f9834f2347764941b1ebb56b9375c074092 (diff) | |
download | pigweed-5bac2a9fc964d4022f2009af5bd2806f9e7c2762.tar.gz |
pw_protobuf: Generate operator!= for Message structs
It's rather awkward to have operator== but not operator!=, as we can't
expect users to write `!(foo1 == foo2)` themselves.
Change-Id: I587fbd01f7bd479a55bb25bab9ebeb3dfc89c8d2
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/117131
Reviewed-by: Matthias Guenther <mrguenther@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Anqi Dong <anqid@google.com>
Diffstat (limited to 'pw_protobuf')
-rw-r--r-- | pw_protobuf/py/pw_protobuf/codegen_pwpb.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/pw_protobuf/py/pw_protobuf/codegen_pwpb.py b/pw_protobuf/py/pw_protobuf/codegen_pwpb.py index 3cfebb03b..78d729582 100644 --- a/pw_protobuf/py/pw_protobuf/codegen_pwpb.py +++ b/pw_protobuf/py/pw_protobuf/codegen_pwpb.py @@ -2108,6 +2108,8 @@ def generate_struct_for_message(message: ProtoMessage, root: ProtoNode, output.write_line('static_cast<void>(other);') output.write_line('return true;') output.write_line('}') + output.write_line('bool operator!=(const Message& other) const ' + '{ return !(*this == other); }') output.write_line('};') |