This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
forward_list::resize take the object to be copied by value?Section: 23.3.7.5[forward.list.modifiers]Status:C++11Submitter: James McNellisOpened: 2010-07-16Last modified: 2023-02-07
Priority:Not Prioritized
View all otherissues in [forward.list.modifiers].
View all issues withC++11 status.
Discussion:
InN3092 [forwardlist.modifiers], theresize() member function is declared as:
void resize(size_type sz, value_type c);
The other sequence containers (list,deque, andvector) take'c' by const reference.
Is there a reason for this difference? If not, thenresize() should be declared as:
void resize(size_type sz, const value_type& c);
The declaration would need to be changed both at its declaration in the classdefinition at [forwardlist]/3 and where its behavior is specifiedat [forwardlist.modifiers]/22.
This would makeforward_list consistent with the CD1 issue679(i).
[Post-Rapperswil]
Daniel changed the P/R slightly, because one paragraph number has been changed since the issuehad been submitted. He also added a similar Requires element that exists in all other containers witharesize member function. He deliberately did not touch the wrong usage of "default-constructed" because thatwill be taken care of by LWG issue868(i).
Moved to Tentatively Ready with revised wording after 5 positive votes on c++std-lib.
[Adopted at 2010-11 Batavia]
Proposed resolution:
forward_list synopsis, as indicated:...void resize(size_type sz);void resize(size_type sz,const value_type& c);void clear();...
void resize(size_type sz);void resize(size_type sz,const value_type& c);27Effects: If
28 -Requires:sz < distance(begin(), end()), erases the lastdistance(begin(), end()) - szelementsfrom the list. Otherwise, insertssz - distance(begin(), end())elements at the end of the list. For the first signature the inserted elements are default constructed, and for the second signature they are copies ofc.Tshall beDefaultConstructiblefor the first form andit shall beCopyConstructiblefor the second form.