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

RandomAccessIterator + 0 #137

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Conversation

RobertLeahy
Copy link
Contributor

Previously the iterators of boost::container::deque would assert when zero was added to them in at least the following situations:

  • The iterator was obtained by a call to boost::container::deque::begin and boost::container::deque::empty returns true
  • The iterator was default constructed

This is inconsistent with the way in which the iterators of boost::container::deque have behaved historically and is also inconsistent with an understanding of iterators developed by analogy with pointers:

  • Adding zero to a null pointer is valid despite the fact the null pointer cannot be dereferenced
  • Adding zero to a pointer that is one past the end yields a pointer which is still one past the end and thus which has well defined semantics

Fixed this issue and codified the expected behavior in unit tests.

Previously the iterators of boost::container::deque would assert when
zero was added to them in at least the following situations:

- The iterator was obtained by a call to boost::container::deque::begin
  and boost::container::deque::empty returns true
- The iterator was default constructed

This is inconsistent with the way in which the iterators of boost::
container::deque have behaved historically and is also inconsistent
with an understanding of iterators developed by analogy with pointers:

- Adding zero to a null pointer is valid despite the fact the null
  pointer cannot be dereferenced
- Adding zero to a pointer that is one past the end yields a pointer
  which is still one past the end and thus which has well defined
  semantics

Fixed this issue and codified the expected behavior in unit tests.
@igaztanaga igaztanaga merged commit d4a0917 into boostorg:develop Jan 14, 2020
@igaztanaga
Copy link
Member

Many thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants