This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
forward_list modifiersSection: 23.3.7.5 [forward.list.modifiers] Status: C++23 Submitter: Tomasz KamiĆski Opened: 2022-11-08 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [forward.list.modifiers].
View all issues with C++23 status.
Discussion:
This is resolution of GB-101 (23.3.7.5 [forward.list.modifiers] p12,15,20,21 Missing preconditions on forward_list modifiers).
Some of the modifiers to forward_list are special to that container and accordingly are not described
in 23.2 [container.requirements]. Specifically, insert_after (iterator overload),
insert_range_after and emplace_after do not verify that the value_type is Cpp17EmplaceConstructible
from the appropriate argument(s).
Furthermore insert_after (value overloads) are missing Cpp17CopyInsertable/Cpp17MoveInsertable
requirements.
[Kona 2022-11-08; Move to Ready]
[Kona 2022-11-12; Correct status to Immediate]
[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N4917.
Modify 23.3.7.5 [forward.list.modifiers] as indicated:
[Drafting note:
emplace_front,push_front, andprepend_rangeare already covered by 23.2 [container.requirements]. ]
iterator insert_after(const_iterator position, const T& x);
-?- Preconditions:
Tis Cpp17CopyInsertable intoforward_list.positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()).-?- Effects: Inserts a copy of
xafterposition.-?- Returns: An iterator pointing to the copy of
x.
iterator insert_after(const_iterator position, T&& x);
-6- Preconditions:
Tis Cpp17MoveInsertable intoforward_list.positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()).-7- Effects: Inserts a copy of
xafterposition.-8- Returns: An iterator pointing to the copy of
x.
iterator insert_after(const_iterator position, size_type n, const T& x);
-9- Preconditions:
Tis Cpp17CopyInsertable intoforward_list.positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()).-10- Effects: Inserts
ncopies ofxafterposition.-11- Returns: An iterator pointing to the last inserted copy of
x, orpositionifn == 0istrue.
template<class InputIterator> iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
-12- Preconditions:
Tis Cpp17EmplaceConstructible intoforward_listfrom*first.positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()). Neitherfirstnorlastare iterators in*this.-13- Effects: Inserts copies of elements in [
first,last) afterposition.-14- Returns: An iterator pointing to the last inserted element, or
positioniffirst == lastistrue.
template<container-compatible-range<T> R> iterator insert_after(const_iterator position, R&& rg);
-15- Preconditions:
Tis Cpp17EmplaceConstructible intoforward_listfrom*ranges::begin(rg).positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()).rgand*thisdo not overlap.-16- Effects: Inserts copies of elements in range
rgafterposition.-17- Returns: An iterator pointing to the last inserted element, or
positionifrgis empty.
iterator insert_after(const_iterator position, initializer_list<T> il);
-18- Effects: Equivalent to:
returninsert_after(position, il.begin(), il.end()).;
-19- Returns: An iterator pointing to the last inserted element orpositionifilis empty.
template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
-20- Preconditions:
Tis Cpp17EmplaceConstructible intoforward_listfromstd::forward<Args>(args)....positionisbefore_begin()or is a dereferenceable iterator in the range [begin(),end()).-21- Effects: Inserts an object of type
value_typeconstructeddirect-non-list-initialized withaftervalue_type(std::forward<Args>(args)...)position.-22- Returns: An iterator pointing to the new object.