[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [certi-dev] Solaris10/SunStudio

From: Eric Noulard
Subject: Re: [certi-dev] Solaris10/SunStudio
Date: Wed, 20 May 2009 09:20:03 +0200

Le 19 mai 2009 23:31, Benoît Bréholée <address@hidden> a écrit :
> Eric Noulard wrote:
>> In the meantime, would you mind trying to replace:
>> // broadcastSomeMessage needs a vector, no set -> conversion
>>  vector<FederateHandle>
>> federate_vector(federate_set.begin(),federate_set.end());
>> by:
>> // broadcastSomeMessage needs a vector, no set -> conversion
>> vector<FederateHandle> federate_vector(federate_set.size());
>> std::copy(federate_set.begin(),federate_set.end(),federate_vector.begin());

Hi Benoit,

Nice to read you. Wasn't even sure you were still reading the list.

> I'd suggest using a back_inserter, something like this:
> std::vector<FederateHandle> federate_vector ;
> std::copy(federate_set.begin(),
>          federate_set.end(),
>          std::back_inserter(federate_vector));
> so that you don't have to worry about the size of federate_vector before
> calling std::copy().

I did not thought of the back_inserter usage it's definitely more STLish.
However now that I'm thinking about it. I may prefer the "size()" usage
which should trigger less memory allocation call because the vector will
have appropriate size from the beginning whereas the back_inserter usage
**may** trigger several re-allocation during the copy.

Thank you very much for your kind eye on CERTI.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]