This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.
forward_list::merge
and forward_list::splice_after
with unequal allocatorsSection: 23.3.7.6 [forward.list.ops] Status: C++14 Submitter: Pablo Halpern Opened: 2011-03-24 Last modified: 2023-02-07
Priority: Not Prioritized
View all other issues in [forward.list.ops].
View all issues with C++14 status.
Discussion:
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.
In [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
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
).get_allocator() == x.get_allocator()
.&x != this
.
In [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
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
). The iterator followingi
is a dereferenceable iterator inx
.get_allocator() == x.get_allocator()
.
In [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
isbefore_begin()
or is a dereferenceable iterator in the range [begin()
,end()
). (first
,last
) is a valid range inx
, 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()
.
In [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
andx
are both sorted according to this ordering.get_allocator() == x.get_allocator()
.