3817. Missing preconditions on forward_list modifiers

Section: 24.3.9.5 [forward.list.modifiers] Status: WP Submitter: Tomasz Kamiński Opened: 2022-11-08 Last modified: 2022-11-15 16:24:02 UTC

Priority: Not Prioritized

View all other issues in [forward.list.modifiers].

View all issues with WP status.

Discussion:

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

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

    [Drafting note: emplace_front, push_front, and prepend_range are already covered by 24.2 [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.