2045. forward_list::merge and forward_list::splice_after with unequal allocators

Section: 26.3.9.6 [forwardlist.ops] Status: C++14 Submitter: Pablo Halpern Opened: 2011-03-24 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [forwardlist.ops].

View all issues with C++14 status.

Discussion:

See also: 1215

list::merge and list::splice have the requirement that the two lists being merged or spliced must use the same allocator. Otherwise, moving list nodes from one container to the other would corrupt the data structure. The same requirement is needed for forward_list::merge and forward_list::splice_after.

[ 2011 Bloomington ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. In 26.3.9.6 [forwardlist.ops] p. 1 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x);
    

    1 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). get_allocator() == x.get_allocator(). &x != this.

  2. In 26.3.9.6 [forwardlist.ops] p. 5 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x, const_iterator i);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x, const_iterator i);
    

    5 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). The iterator following i is a dereferenceable iterator in x. get_allocator() == x.get_allocator().

  3. In 26.3.9.6 [forwardlist.ops] p. 9 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x, 
                      const_iterator first, const_iterator last);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x, 
                      const_iterator first, const_iterator last);
    

    9 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). (first,last) is a valid range in x, and all iterators in the range (first,last) are dereferenceable. position is not an iterator in the range (first,last). get_allocator() == x.get_allocator().

  4. In 26.3.9.6 [forwardlist.ops] p. 18 change as indicated:

    void merge(forward_list<T,Allocator>& x);
    void merge(forward_list<T,Allocator>&& x);
    template <class Compare> void merge(forward_list<T,Allocator>& x, Compare comp);
    template <class Compare> void merge(forward_list<T,Allocator>&& x, Compare comp);
    

    18 - Requires: comp defines a strict weak ordering ([alg.sorting]), and *this and x are both sorted according to this ordering. get_allocator() == x.get_allocator().