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

insert_iterator and ostreambuf_iterator don't properly support *o++ = t; #302

Closed
CaseyCarter opened this issue Dec 8, 2016 · 2 comments
Closed

Comments

@CaseyCarter
Copy link
Collaborator

CaseyCarter commented Dec 8, 2016

See the discussion at CaseyCarter/cmcstl2#60 (comment). Both iterators internally store state that must be updated on each write. We made a blanket change to have output iterators' operator++(int) return a copy instead of a reference after the discussion in #137 (and IIRC discussion with LWG at Kona) we broke insert_iterator and ostreambuf_iterator. The expression *o++ = t results in updating the state of the temporary immediately before throwing it on the floor. Later use of the iterator sees the "old" state and does terrible things.

The fix is to change the postfix increment of at least insert_iterator and ostreambuf_iterator, if not all of the output iterators specified in the TS, to again return by reference as in Standard C++.

Proposed Resolution

Adopt P0541.

@ericniebler
Copy link
Owner

Will be addressed by P0541. See https://github.com/ericniebler/stl2/blob/master/ext/post_inc/post_inc.md for wording.

@ericniebler
Copy link
Owner

P0541 was moved to ready in Kona.

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

No branches or pull requests

2 participants