From c85b6d72e6259ae6c308b9bd746b6fa5eaca28ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Thu, 3 Oct 2024 09:50:38 +0200 Subject: [PATCH] Improve equality operator for unions (#409) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../fastcdr/idl/templates/TypesHeader.stg | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg index e6f62638..634c7e87 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -402,16 +402,25 @@ public: { bool ret_value {false}; - if (m__d == x.m__d && - selected_member_ == x.selected_member_) + if (x.selected_member_ == selected_member_) { - switch (selected_member_) + if (0x0FFFFFFFu != selected_member_) { - $union.members:{ member | - case $member.id$: - ret_value = (m_$member.name$ == x.m_$member.name$); - break; - }; separator="\n"$ + if (x.m__d == m__d) + { + switch (selected_member_) + { + $union.members:{ member | + case $member.id$: + ret_value = (x.m_$member.name$ == m_$member.name$); + break; + }; separator="\n"$ + } + } + } + else + { + ret_value = true; } }