Title
Missing preconditions on forward_list modifiers
Status
c++23
Section
[forward.list.modifiers]
Submitter
Tomasz Kamiński

Created on 2022-11-08.00:00:00 last changed 13 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to N4917.

  1. Modify [forward.list.modifiers] as indicated:

    [Drafting note: emplace_front, push_front, and prepend_range are already covered by [container.requirements]. ]

    iterator insert_after(const_iterator position, const T& x);
    

    -?- Preconditions: T is Cpp17CopyInsertable into forward_list. position is before_begin() or is a dereferenceable iterator in the range [begin(), end()).

    -?- Effects: Inserts a copy of x after position.

    -?- Returns: An iterator pointing to the copy of x.

    iterator insert_after(const_iterator position, T&& x);
    

    -6- Preconditions: T is Cpp17MoveInsertable into forward_list. position is before_begin() or is a dereferenceable iterator in the range [begin(), end()).

    -7- Effects: Inserts a copy of x after position.

    -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 into forward_list. position is before_begin() or is a dereferenceable iterator in the range [begin(), end()).

    -10- Effects: Inserts n copies of x after position.

    -11- Returns: An iterator pointing to the last inserted copy of x, or position if n == 0 is true.

    template<class InputIterator>	
      iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
    

    -12- Preconditions: T is Cpp17EmplaceConstructible into forward_list from *first. position is before_begin() or is a dereferenceable iterator in the range [begin(), end()). Neither first nor last are iterators in *this.

    -13- Effects: Inserts copies of elements in [first, last) after position.

    -14- Returns: An iterator pointing to the last inserted element, or position if first == last is true.

    template<container-compatible-range<T> R>
      iterator insert_after(const_iterator position, R&& rg);
    

    -15- Preconditions: T is Cpp17EmplaceConstructible into forward_list from *ranges::begin(rg). position is before_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 after position.

    -17- Returns: An iterator pointing to the last inserted element, or position if rg 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 or position if il is empty.

    template<class... Args>	
      iterator emplace_after(const_iterator position, Args&&... args);
    

    -20- Preconditions: T is Cpp17EmplaceConstructible into forward_list from std::forward<Args>(args).... position is before_begin() or is a dereferenceable iterator in the range [begin(), end()).

    -21- Effects: Inserts an object of type value_type constructeddirect-non-list-initialized with value_type(std::forward<Args>(args)...) after position.

    -22- Returns: An iterator pointing to the new object.

Date: 2022-11-12.00:00:00

[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP. ]

Date: 2022-11-12.01:55:04

[ Kona 2022-11-12; Correct status to Immediate ]

Date: 2022-11-11.00:03:23

[ Kona 2022-11-08; Move to Ready ]

Date: 2022-11-08.00:00:00

This is resolution of GB-101 ([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 [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.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13095
2022-11-17 00:42:33adminsetstatus: immediate -> wp
2022-11-12 01:55:04adminsetmessages: + msg13039
2022-11-12 01:55:04adminsetstatus: ready -> immediate
2022-11-11 00:03:23adminsetmessages: + msg13015
2022-11-11 00:03:23adminsetstatus: new -> ready
2022-11-08 16:38:45adminsetmessages: + msg12961
2022-11-08 00:00:00admincreate