Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the return type of vector::erase from iterator to bool #1662

Closed
FerdinandSpitzschnueffler opened this issue Sep 23, 2022 · 0 comments · Fixed by #1665
Closed

Change the return type of vector::erase from iterator to bool #1662

FerdinandSpitzschnueffler opened this issue Sep 23, 2022 · 0 comments · Fixed by #1665
Assignees
Labels
globex refactoring Refactor code without adding features
Milestone

Comments

@FerdinandSpitzschnueffler
Copy link
Contributor

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.

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler added the refactoring Refactor code without adding features label Sep 23, 2022
@FerdinandSpitzschnueffler FerdinandSpitzschnueffler added this to the High prio milestone Sep 23, 2022
FerdinandSpitzschnueffler added a commit to ApexAI/iceoryx that referenced this issue Sep 23, 2022
FerdinandSpitzschnueffler added a commit to ApexAI/iceoryx that referenced this issue Sep 23, 2022
FerdinandSpitzschnueffler added a commit to ApexAI/iceoryx that referenced this issue Sep 23, 2022
FerdinandSpitzschnueffler added a commit to ApexAI/iceoryx that referenced this issue Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
globex refactoring Refactor code without adding features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant