Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > vector assign() trouble

Thread Tools

vector assign() trouble

Victor Bazarov
Posts: n/a
Roland Pibinger wrote:
> On Mon, 8 Jan 2007 20:10:54 -0500, "Victor Bazarov" wrote:
>> I would guess that the function is for repeated use with already
>> created vector (no need to reconstruct it). The following does the
>> same thing
>> existingvector.swap(std::vector(s.begin(), s.end()));

> You cannot use a temporary with vector::swap().

Right. It ought to be the other way around:

std::vector(s.begin(), s.end()).swap(existingvector);

Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Reply With Quote
peter koch
Posts: n/a

Sylvester Hesp skrev:
> "peter koch" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)
> >
> > As Victor already pointed out, assign assigns and does not create new
> > elements.

> I'm sorry but that's just nonsense. The assign function does the same as
> it's corresponding constructor in vector, namelijk reconstructing the vector
> with the range of elements you've provided.


Right. One of the (few) times that Victor was wrong and my appeal to
authority became to strong


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Free memory allocate by a STL vector, vector of vector, map of vector C++ 8 02-18-2006 12:48 AM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM
how do i create a vector within a vector ? learningjava Java 5 10-17-2003 10:19 PM