Skip to content

Commit 502e28b

Browse files
committed
iox-#2277 Add nodiscard to iox containers when pushing/emplacing fails
1 parent f069696 commit 502e28b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

iceoryx_hoofs/container/include/iox/forward_list.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ class forward_list
179179
/// @brief add element to the beginning of the list
180180
/// @param[in] data reference to data element
181181
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
182-
bool push_front(const T& data) noexcept;
182+
[[nodiscard]] bool push_front(const T& data) noexcept;
183183

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

189189
/// @brief remove the first element from the begining of the list
190190
/// element destructor will be invoked

iceoryx_hoofs/container/include/iox/list.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,22 @@ class list
175175
/// @brief add element to the beginning of the list
176176
/// @param[in] data reference to data element
177177
/// @return successful insertion (true), otherwise no element could be added to list (e.g. full -> false)
178-
bool push_front(const T& data) noexcept;
178+
[[nodiscard]] bool push_front(const T& data) noexcept;
179179

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

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

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

195195
/// @brief remove the first element from the begining of the list
196196
/// element destructor will be invoked

iceoryx_hoofs/container/include/iox/vector.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,32 +180,32 @@ class vector final
180180
/// creates two new elements via move construction. The first one has a valid source but the second
181181
/// gets an already moved parameter.
182182
template <typename... Targs>
183-
bool resize(const uint64_t count, const Targs&... args) noexcept;
183+
[[nodiscard]] bool resize(const uint64_t count, const Targs&... args) noexcept;
184184

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

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

200200
/// @brief appends the given element at the end of the vector
201201
/// @param[in] value to append to the vector
202202
/// @return true if successful, false if vector already full
203-
bool push_back(const T& value) noexcept;
203+
[[nodiscard]] bool push_back(const T& value) noexcept;
204204

205205
/// @brief appends the given element at the end of the vector
206206
/// @param[in] value to append to the vector
207207
/// @return true if successful, false if vector already full
208-
bool push_back(T&& value) noexcept;
208+
[[nodiscard]] bool push_back(T&& value) noexcept;
209209

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

0 commit comments

Comments
 (0)