Skip to content

Commit

Permalink
iox-#2277 Add nodiscard to iox containers when pushing/emplacing fails
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Barone <[email protected]>
  • Loading branch information
pbarone-latai committed Apr 24, 2024
1 parent f069696 commit 651eca2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
- Create a flat include structure for `iceoryx_hoofs` [#1593](https://github.com/eclipse-iceoryx/iceoryx/issues/1593)
- Handle 'strerror_r' idiosyncrasies in the platform layer [#1616](https://github.com/eclipse-iceoryx/iceoryx/issues/1616)
- Fix new clang-tidy-18 warnings [#2274](https://github.com/eclipse-iceoryx/iceoryx/issues/2274)
- Adding `[[nodiscard]]` to iox containers which may fail and return false if at capacity [#2277](https://github.com/eclipse-iceoryx/iceoryx/issues/2277)

**Workflow:**

Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/container/include/iox/forward_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ class forward_list
/// @brief add element to the beginning of the list
/// @param[in] data reference to data element
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_front(const T& data) noexcept;
[[nodiscard]] bool push_front(const T& data) noexcept;

/// @brief add element to the beginning of the list via move
/// @param[in] data universal reference perfectly forwarded to client class
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_front(T&& data) noexcept;
[[nodiscard]] bool push_front(T&& data) noexcept;

/// @brief remove the first element from the begining of the list
/// element destructor will be invoked
Expand Down
8 changes: 4 additions & 4 deletions iceoryx_hoofs/container/include/iox/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,22 @@ class list
/// @brief add element to the beginning of the list
/// @param[in] data reference to data element
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_front(const T& data) noexcept;
[[nodiscard]] bool push_front(const T& data) noexcept;

/// @brief add element to the beginning of the list via move
/// @param[in] data universal reference perfectly forwarded to client class
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_front(T&& data) noexcept;
[[nodiscard]] bool push_front(T&& data) noexcept;

/// @brief add element to the end of the list
/// @param[in] data reference to data element
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_back(const T& data) noexcept;
[[nodiscard]] bool push_back(const T& data) noexcept;

/// @brief add element to the end of the list via move
/// @param[in] data universal reference perfectly forwarded to client class
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
bool push_back(T&& data) noexcept;
[[nodiscard]] bool push_back(T&& data) noexcept;

/// @brief remove the first element from the begining of the list
/// element destructor will be invoked
Expand Down
10 changes: 5 additions & 5 deletions iceoryx_hoofs/container/include/iox/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,32 @@ class vector final
/// creates two new elements via move construction. The first one has a valid source but the second
/// gets an already moved parameter.
template <typename... Targs>
bool resize(const uint64_t count, const Targs&... args) noexcept;
[[nodiscard]] bool resize(const uint64_t count, const Targs&... args) noexcept;

/// @brief forwards all arguments to the constructor of the contained element
/// and performs a placement new at the provided position
/// @param[in] position the position where the element should be created
/// @param[in] args arguments which are used by the constructor of the newly created argument
/// @return true if successful, false if position is greater than size or the vector is already full
template <typename... Targs>
bool emplace(const uint64_t position, Targs&&... args) noexcept;
[[nodiscard]] bool emplace(const uint64_t position, Targs&&... args) noexcept;

/// @brief forwards all arguments to the constructor of the contained element
/// and performs a placement new at the end
/// @param[in] args arguments which are used by the constructor of the newly created argument
/// @return true if successful, false if the vector is already full
template <typename... Targs>
bool emplace_back(Targs&&... args) noexcept;
[[nodiscard]] bool emplace_back(Targs&&... args) noexcept;

/// @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
bool push_back(const T& value) noexcept;
[[nodiscard]] bool push_back(const T& value) noexcept;

/// @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
bool push_back(T&& value) noexcept;
[[nodiscard]] bool push_back(T&& value) noexcept;

/// @brief removes the last element of the vector; calling pop_back on an empty container does nothing
/// @return true if the last element was removed. If the vector is empty it returns false.
Expand Down

0 comments on commit 651eca2

Please sign in to comment.