Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2277 Add nodiscard to iox containers when pushing…
Browse files Browse the repository at this point in the history
…/emplacing fails
  • Loading branch information
pbarone-latai committed Apr 24, 2024
1 parent f069696 commit 502e28b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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 502e28b

Please sign in to comment.