std::vector::resize should take a const reference - by RobYull

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 692988 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 10/4/2011 5:50:22 AM
Access Restriction Public

Description

There was an old closed ticket on this - https://connect.microsoft.com/VisualStudio/feedback/details/173440/std-vector-resize-should-take-a-const-reference - but I thought I'd try to push this again.

The original response was: "After some investigation, we concluded that the current behavior is in line with the requirements of C++ standard and we are not planning to change the implementation.".

From the <vector> header:
void resize(size_type _Newsize, _Ty _Val)

The standard says it should be
// 23.3.6.3, capacity:
void resize(size_type sz, const T& c);

I don't believe that it is truly inline with the standard, since the current version has the possibility of calling the copy-constructor of the stored data type.
Sign in to post a comment.
Posted by Microsoft on 11/4/2011 at 8:34 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11.

Amusingly, when this was originally reported in July 2006 (months before I joined the VC team), this was indeed By Design. C++03 23.2.4.2 [lib.vector.capacity]/6 specified:

void resize(size_type sz, T c = T());

Now, C++11 23.3.6.3 [vector.capacity]/9, 11 specifies:

void resize(size_type sz);
void resize(size_type sz, const T& c);

This change was introduced in March 2008's Working Paper N2588.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by EricLeong [Feedback Moderator] on 10/4/2011 at 6:47 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 10/4/2011 at 6:44 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)