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
Change the return type of vector::erase from iterator to bool indicating whether the erase operation was successful.
Detailed information
In the current implementation a nullptr is returned when the provided position is invalid, i.e. out of bounds. When the last element is removed, end() is returned. Dereferencing these leads to undefined behavior. Even though validating pointers/iterators before dereferencing is the responsibility of the user we could make our code much safer when implementing the proposed change.
The text was updated successfully, but these errors were encountered:
Brief feature description
Change the return type of
vector::erase
from iterator to bool indicating whether the erase operation was successful.Detailed information
In the current implementation a nullptr is returned when the provided position is invalid, i.e. out of bounds. When the last element is removed,
end()
is returned. Dereferencing these leads to undefined behavior. Even though validating pointers/iterators before dereferencing is the responsibility of the user we could make our code much safer when implementing the proposed change.The text was updated successfully, but these errors were encountered: