-
Notifications
You must be signed in to change notification settings - Fork 1.6k
P0896R4 changes to insert iterators #589
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
Conversation
When `defined(__cpp_lib_concepts)`, `(back_|front_|)insert_iterator` are default constructible, and have `ptrdiff_t` as difference type.
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loogs good even when I dread the merge conflicts
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it a bit more I have to take my approval back.
We just handed the users a great way to shoot themselfs in the foot and speaking from experience they will gladly do so. I would assume we should mitigate against some of that:
- Any operation on a default constructed
*_insert_iteratoris an invalid operation. So I would suggest
ifdef __cpp_lib_concepts
#if _ITERATOR_DEBUG_LEVEL >= 1
_STL_VERIFY(container, "cannot {dereference, increment} value-initialized *_insert_iterator");
#endif // _ITERATOR_DEBUG_LEVEL >= 1
ifdef // __cpp_lib_concepts-
It feels rather inconsitent that we require the -real- constructors to be
explicitand happily let the user default construct them anyway. Addingexplicitrequires an LWG-issue right? -
If we are already looking at concepts should they actually be constrained by something along those lines
ifdef __cpp_lib_concepts
requires requires(_Container& __c) { __c.push_back(); }
ifdef // __cpp_lib_conceptsAnother LWG issue maybe?
Dereference and increment (since they have no effects) are well-defined for all three insert iterator types.
WG21 traditionally annotates single-argument converting constructors as
This probably needs a design paper. For Ranges, Eric and I decided that our goal was to conceptualize the algorithms and we deliberately put other kinds of concept constraints out of scope. We didn't want standardize ad hoc/poorly designed concepts (not that we didn't have some) to cover specific cases that might later interfere with "proper" conceptualization of containers and/or iostreams. |
Use direct-list-init instead of copy-list-init for `insert_iterator::iter`. Co-Authored-By: Stephan T. Lavavej <stl@nuwen.net>
|
Plesse do not trouble you too much with merge conflicts with other PRs. It is totally fine to resolve those in the other PR. I will hiss and wail though but that is fine |
| #ifdef __cpp_lib_concepts | ||
| using difference_type = ptrdiff_t; | ||
|
|
||
| insert_iterator() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity: Why isn't this one constexpr (in the standard)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have absolutely no idea. (To be honest, I don't understand why we ever put an explicit constexpr on a defaulted default constructor.) These default constructors came from P0896, which crossed with P1032 that added constexpr to all of the members of the insert iterators, and apparently the editors decided to put constexpr on some subset of the default constructors for reasons not apparent to me.
barcharcraz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
When `defined(__cpp_lib_concepts)`, `(back_|front_|)insert_iterator` are default constructible, and have `ptrdiff_t` as difference type. Skip libc++ tests broken by this change.
Description
When
defined(__cpp_lib_concepts),(back_|front_|)insert_iteratorare default constructible, and haveptrdiff_tas difference type.Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Uglyas perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
the C++ Working Draft (including any cited standards), other WG21 papers
(excluding reference implementations outside of proposed standard wording),
and LWG issues as reference material. If they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.