From 88b60ed823629d5382a6a8f7e1b17ac779c18bd5 Mon Sep 17 00:00:00 2001 From: CursedRock17 Date: Sun, 21 Apr 2024 00:25:16 -0400 Subject: [PATCH 1/2] Global use of nodiscard Signed-off-by: CursedRock17 --- .../include/rosidl_runtime_cpp/action_type_support_decl.hpp | 1 + .../include/rosidl_runtime_cpp/bounded_vector.hpp | 6 ++++++ .../rosidl_runtime_cpp/message_type_support_decl.hpp | 1 + .../rosidl_runtime_cpp/service_type_support_decl.hpp | 1 + .../rosidl_runtime_cpp/type_description/field__struct.hpp | 2 ++ .../type_description/field_type__struct.hpp | 2 ++ .../individual_type_description__struct.hpp | 2 ++ .../type_description/key_value__struct.hpp | 2 ++ .../type_description/type_description__struct.hpp | 2 ++ .../type_description/type_source__struct.hpp | 2 ++ .../include/rosidl_typesupport_cpp/action_type_support.hpp | 1 + .../include/rosidl_typesupport_cpp/message_type_support.hpp | 1 + .../include/rosidl_typesupport_cpp/service_type_support.hpp | 1 + .../message_type_support_decl.hpp | 1 + .../service_type_support_decl.hpp | 1 + 15 files changed, 26 insertions(+) diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp index 193567855..11c8d98d7 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_runtime_cpp * \return Function handler for the action's typesupport. */ template +[[nodiscard]] const rosidl_action_type_support_t * get_action_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp index f2fa3c0b5..cad016f1b 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp @@ -714,6 +714,7 @@ class BoundedVector * \param y A %BoundedVector of the same type as @a x * \return True if the size and elements of the vectors are equal */ + [[nodiscard]] friend bool operator==( const BoundedVector & x, @@ -734,6 +735,7 @@ class BoundedVector * \param y A %BoundedVector of the same type as @a x * @return True if @a x is lexicographically less than @a y */ + [[nodiscard]] friend bool operator<( const BoundedVector & x, @@ -743,6 +745,7 @@ class BoundedVector } /// Based on operator== + [[nodiscard]] friend bool operator!=( const BoundedVector & x, @@ -752,6 +755,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator>( const BoundedVector & x, @@ -761,6 +765,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator<=( const BoundedVector & x, @@ -770,6 +775,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator>=( const BoundedVector & x, diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_type_support_decl.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_type_support_decl.hpp index 69cf8de39..c6c9e4735 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_type_support_decl.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_runtime_cpp * \return Function handler for the message's typesupport. */ template +[[nodiscard]] const rosidl_message_type_support_t * get_message_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp index 80eeb79fd..0f024bb6c 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_runtime_cpp * \return Function handler for the service's typesupport. */ template +[[nodiscard]] const rosidl_service_type_support_t * get_service_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp index 210af6b71..9e51a7792 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp @@ -133,6 +133,7 @@ struct Field_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const Field_ & other) const { if (this->name != other.name) { @@ -146,6 +147,7 @@ struct Field_ } return true; } + [[nodiscard]] bool operator!=(const Field_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp index 63cb2a55c..d22b67522 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp @@ -335,6 +335,7 @@ struct FieldType_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const FieldType_ & other) const { if (this->type_id != other.type_id) { @@ -351,6 +352,7 @@ struct FieldType_ } return true; } + [[nodiscard]] bool operator!=(const FieldType_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp index 890a396b9..2eb491aee 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp @@ -119,6 +119,7 @@ struct IndividualTypeDescription_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const IndividualTypeDescription_ & other) const { if (this->type_name != other.type_name) { @@ -129,6 +130,7 @@ struct IndividualTypeDescription_ } return true; } + [[nodiscard]] bool operator!=(const IndividualTypeDescription_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp index 7cd25f6c1..86e95c2ca 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp @@ -118,6 +118,7 @@ struct KeyValue_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const KeyValue_ & other) const { if (this->key != other.key) { @@ -128,6 +129,7 @@ struct KeyValue_ } return true; } + [[nodiscard]] bool operator!=(const KeyValue_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp index a56949cd2..8c74cbc77 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp @@ -113,6 +113,7 @@ struct TypeDescription_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const TypeDescription_ & other) const { if (this->type_description != other.type_description) { @@ -123,6 +124,7 @@ struct TypeDescription_ } return true; } + [[nodiscard]] bool operator!=(const TypeDescription_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp index 7ee8385e8..9c3cb7924 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp @@ -130,6 +130,7 @@ struct TypeSource_ ConstPtr; // comparison operators + [[nodiscard]] bool operator==(const TypeSource_ & other) const { if (this->type_name != other.type_name) { @@ -143,6 +144,7 @@ struct TypeSource_ } return true; } + [[nodiscard]] bool operator!=(const TypeSource_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp index e0befe2bc..2d0171a73 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp @@ -22,6 +22,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_action_type_support_t * get_action_type_support_handle(); } // namespace rosidl_typesupport_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp index 6fad1d7d5..af0064efd 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp @@ -22,6 +22,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_message_type_support_t * get_message_type_support_handle(); } // namespace rosidl_typesupport_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp index 2931b8736..23b3e8a45 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp @@ -25,6 +25,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_service_type_support_t * get_service_type_support_handle(); template diff --git a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp index 97eece341..3666c49dd 100644 --- a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp +++ b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp @@ -28,6 +28,7 @@ namespace rosidl_typesupport_introspection_cpp /// the rosidl_generate_interfaces() macro. /// This is implemented in the shared library provided by this package. template +[[nodiscard]] ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_message_type_support_t * get_message_type_support_handle(); diff --git a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp index eaa3db906..bcc6ac858 100644 --- a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp +++ b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_typesupport_introspection_cpp /// services. /// This is implemented in the shared library provided by this package. template +[[nodiscard]] ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_service_type_support_t * get_service_type_support_handle(); From 6f965d712cf61bed8d4e0fc69c542906efd55709 Mon Sep 17 00:00:00 2001 From: CursedRock17 Date: Tue, 23 Apr 2024 13:12:17 -0400 Subject: [PATCH 2/2] Removing type_description nodiscard Signed-off-by: CursedRock17 --- .../rosidl_runtime_cpp/type_description/field__struct.hpp | 2 -- .../rosidl_runtime_cpp/type_description/field_type__struct.hpp | 2 -- .../type_description/individual_type_description__struct.hpp | 2 -- .../rosidl_runtime_cpp/type_description/key_value__struct.hpp | 2 -- .../type_description/type_description__struct.hpp | 2 -- .../rosidl_runtime_cpp/type_description/type_source__struct.hpp | 2 -- 6 files changed, 12 deletions(-) diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp index 9e51a7792..210af6b71 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field__struct.hpp @@ -133,7 +133,6 @@ struct Field_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const Field_ & other) const { if (this->name != other.name) { @@ -147,7 +146,6 @@ struct Field_ } return true; } - [[nodiscard]] bool operator!=(const Field_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp index d22b67522..63cb2a55c 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/field_type__struct.hpp @@ -335,7 +335,6 @@ struct FieldType_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const FieldType_ & other) const { if (this->type_id != other.type_id) { @@ -352,7 +351,6 @@ struct FieldType_ } return true; } - [[nodiscard]] bool operator!=(const FieldType_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp index 2eb491aee..890a396b9 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/individual_type_description__struct.hpp @@ -119,7 +119,6 @@ struct IndividualTypeDescription_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const IndividualTypeDescription_ & other) const { if (this->type_name != other.type_name) { @@ -130,7 +129,6 @@ struct IndividualTypeDescription_ } return true; } - [[nodiscard]] bool operator!=(const IndividualTypeDescription_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp index 86e95c2ca..7cd25f6c1 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/key_value__struct.hpp @@ -118,7 +118,6 @@ struct KeyValue_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const KeyValue_ & other) const { if (this->key != other.key) { @@ -129,7 +128,6 @@ struct KeyValue_ } return true; } - [[nodiscard]] bool operator!=(const KeyValue_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp index 8c74cbc77..a56949cd2 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_description__struct.hpp @@ -113,7 +113,6 @@ struct TypeDescription_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const TypeDescription_ & other) const { if (this->type_description != other.type_description) { @@ -124,7 +123,6 @@ struct TypeDescription_ } return true; } - [[nodiscard]] bool operator!=(const TypeDescription_ & other) const { return !this->operator==(other); diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp index 9c3cb7924..7ee8385e8 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/type_source__struct.hpp @@ -130,7 +130,6 @@ struct TypeSource_ ConstPtr; // comparison operators - [[nodiscard]] bool operator==(const TypeSource_ & other) const { if (this->type_name != other.type_name) { @@ -144,7 +143,6 @@ struct TypeSource_ } return true; } - [[nodiscard]] bool operator!=(const TypeSource_ & other) const { return !this->operator==(other);