You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marking any operation in iox containers which may fail and return bool as [[nodiscard]]
Detailed information
The idea here is pretty straightforward. Taking iox::vector for example, the API for push back returns bool as compared to void of std::vector::push_back.
/// @brief appends the given element at the end of the vector
/// @param[in] value to append to the vector
/// @return true if successful, false if vector already full
boolpush_back(const T& value) noexcept;
Marking this code as [[nodiscard]] will raise compiler warnings in the event that a user is pushing back blindly onto an iox::vector and not handling the case where it fails. If the user has performed size checks at the beginning of a loop, they can simply use ...
std::ignore = my_iox_vector.push_back(value);
If the iceoryx team is aligned with this approach, I can put up a PR to add the nodiscards
The text was updated successfully, but these errors were encountered:
Brief feature description
Marking any operation in iox containers which may fail and return bool as
[[nodiscard]]
Detailed information
The idea here is pretty straightforward. Taking
iox::vector
for example, the API for push back returnsbool
as compared tovoid
ofstd::vector::push_back
.iceoryx/iceoryx_hoofs/container/include/iox/vector.hpp
Lines 200 to 203 in f069696
Marking this code as
[[nodiscard]]
will raise compiler warnings in the event that a user is pushing back blindly onto aniox::vector
and not handling the case where it fails. If the user has performed size checks at the beginning of a loop, they can simply use ...If the iceoryx team is aligned with this approach, I can put up a PR to add the nodiscards
The text was updated successfully, but these errors were encountered: