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_range
are already covered by 23.2 [container.requirements]. ]
iterator insert_after(const_iterator position, const T& x);
-?- Preconditions:
T
is Cpp17CopyInsertable intoforward_list
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).-?- Effects: Inserts a copy of
x
afterposition
.-?- Returns: An iterator pointing to the copy of
x
.
iterator insert_after(const_iterator position, T&& x);
-6- Preconditions:
T
is Cpp17MoveInsertable intoforward_list
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).-7- Effects: Inserts a copy of
x
afterposition
.-8- Returns: An iterator pointing to the copy of
x
.
iterator insert_after(const_iterator position, size_type n, const T& x);
-9- Preconditions:
T
is Cpp17CopyInsertable intoforward_list
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).-10- Effects: Inserts
n
copies ofx
afterposition
.-11- Returns: An iterator pointing to the last inserted copy of
x
, orposition
ifn == 0
istrue
.
template<class InputIterator> iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
-12- Preconditions:
T
is Cpp17EmplaceConstructible intoforward_list
from*first
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
). Neitherfirst
norlast
are iterators in*this
.-13- Effects: Inserts copies of elements in [
first
,last
) afterposition
.-14- Returns: An iterator pointing to the last inserted element, or
position
iffirst == last
istrue
.
template<container-compatible-range<T> R> iterator insert_after(const_iterator position, R&& rg);
-15- Preconditions:
T
is Cpp17EmplaceConstructible intoforward_list
from*ranges::begin(rg)
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).rg
and*this
do not overlap.-16- Effects: Inserts copies of elements in range
rg
afterposition
.-17- Returns: An iterator pointing to the last inserted element, or
position
ifrg
is empty.
iterator insert_after(const_iterator position, initializer_list<T> il);
-18- Effects: Equivalent to:
return
insert_after(position, il.begin(), il.end())
.;
-19- Returns: An iterator pointing to the last inserted element orposition
ifil
is empty.
template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
-20- Preconditions:
T
is Cpp17EmplaceConstructible intoforward_list
fromstd::forward<Args>(args)...
.position
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).-21- Effects: Inserts an object of type
value_type
constructeddirect-non-list-initialized withafter
value_type(std::forward<Args>(args)...)position
.-22- Returns: An iterator pointing to the new object.