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

set::iterator should be constant #176

Open
alexkaratarakis opened this issue Jan 13, 2021 · 0 comments
Open

set::iterator should be constant #176

alexkaratarakis opened this issue Jan 13, 2021 · 0 comments

Comments

@alexkaratarakis
Copy link

boost::container::set's iterator is a mutable iterator. This allows modification of keys, which can destroy the container's invariants, for example when using the erase-remove idiom.
This used to be a defect in std::set as well but has been fixed.
As can be seen in cppreference

iterator | Constant LegacyBidirectionalIterator
const_iterator | Constant LegacyBidirectionalIterator

and in stdlib:

      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // DR 103. set::iterator is required to be modifiable,
      // but this allows modification of keys.
      typedef typename _Rep_type::const_iterator	 iterator;
      typedef typename _Rep_type::const_iterator	 const_iterator;
@alexkaratarakis alexkaratarakis changed the title set::iterator should be constant set::iterator should be constant Jan 13, 2021
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

No branches or pull requests

1 participant