STL last arg to vector::resize

Howard Hinnant hhinnant@apple.com
Tue Aug 21 15:37:00 GMT 2007


On Aug 17, 2007, at 10:51 PM, Jonathan Wakely wrote:

> On 18/08/07, John L. Kulp <jlkjr@bioleap.com> wrote:
>> Can anyone give me the rationale about why vector::resize passes  
>> its last argument by value?  On the surface it seems wrong to incur  
>> the cost of copying for no reason I can see. Also, MSVC and gcc  
>> disagree about whether the arg should be const.  Again, is there  
>> any reason it shouldn't be?  Perhaps this has been discussed, in  
>> which case could someone point me to that?  Thanks.  Note that  
>> passing by value means that aligned vectors as required for SSE  
>> code will fail to compile due to this.
>
> See http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#679
> for a summary of why it works like that today. I don't know if Howard
> would recommend GCC should change the signature before that issue is
> resolved one way or another.

I recommend waiting, as this is an ABI breaking change (I consider  
this ABI breakage acceptable, but all such breakage should occur at  
one point).  Also changing this signature in the standard is far from  
a shoe-in.

-Howard



More information about the Libstdc++ mailing list