Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std containers and memory

Reply
Thread Tools

std containers and memory

 
 
Dylan
Guest
Posts: n/a
 
      05-18-2005
If I reserve some memory for a std container, let's say

std::vector<int> myInts;
myInts.reserve(100);

and then allocate another std:vector to it, like so:

std::vector<int> myOtherInts(30, 10);

myInts = myOtherInts;

Is myInts using the reserved memory or allocating a new block?

thanks
 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      05-18-2005
Dylan wrote:
> If I reserve some memory for a std container, let's say
>
> std::vector<int> myInts;
> myInts.reserve(100);
>
> and then allocate another std:vector to it, like so:
>
> std::vector<int> myOtherInts(30, 10);
>
> myInts = myOtherInts;
>
> Is myInts using the reserved memory or allocating a new block?


That's probably implementation specific. I don't believe the standard
mandates any particular behaviour.
 
Reply With Quote
 
 
 
Reply

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
Are sequence containers not a subset of general containers? Sebastian Mach C++ 5 10-06-2012 07:54 PM
Containers of iterators vs. containers of references clark.coleman@att.net C++ 7 01-25-2008 01:37 PM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
std::map<int,std::set<std::string> > Wrong? (Segmentation fault.) Peter Jansson C++ 5 03-17-2005 06:34 AM
Is it a right way for using containers std::list< std::string > strList ? Anton C++ 1 08-06-2003 02:10 PM



Advertisments