Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #41258
| Newsgroups | comp.lang.c++ |
|---|---|
| Date | 2016-02-26 09:00 -0800 |
| References | <5735d6ff-0572-41ff-ac88-8b1bcd52cef6@googlegroups.com> <fOOdnXanTNJK503LnZ2dnUU78W-dnZ2d@giganews.com> |
| Message-ID | <ec35c568-9509-4e07-b7ac-2e93cfb25b44@googlegroups.com> (permalink) |
| Subject | Re: do shared_ptrs to resized vector remain valid? |
| From | jomarbueyes@hotmail.com |
On Friday, February 26, 2016 at 11:18:42 AM UTC-5, Paavo Helde wrote: > On 26.02.2016 17:41, jomarREMOVEbueyes at hotREMOVEmail dot com wrote: > > Hi, > > > > I'm using a few shared pointers to a large vector that might be resized (pointers to the vector itself, not to individual elements). My question is: Do all the shared pointers still point to the vector after it is resized? Thus far, it seems that they do with g++ version 5.2.0. However, for portability I'd like to know what the standard says. > > std::vector consists of the std::vector object itself and of a separate > resizable buffer containing the elements. Once created, the std::vector > object stays at the same location in memory (an object in C++ *is* an > area of memory) until it is destroyed, so any smart or non-smart > pointers to it remain valid during its lifetime. > > With the elements in the resizable buffer the things are different, > their location can change during operations like resizing, so the > pointers and references to the elements can become invalid - but you > already know that. > > hth > Paavo Hi Paavo, Thank you very much for your response. It really helps. Thanks again, Jomar
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
do shared_ptrs to resized vector remain valid? jomarbueyes@hotmail.com - 2016-02-26 07:41 -0800
Re: do shared_ptrs to resized vector remain valid? Paavo Helde <myfirstname@osa.pri.ee> - 2016-02-26 18:18 +0200
Re: do shared_ptrs to resized vector remain valid? legalize+jeeves@mail.xmission.com (Richard) - 2016-02-26 16:56 +0000
Re: do shared_ptrs to resized vector remain valid? jomarbueyes@hotmail.com - 2016-02-26 09:05 -0800
Re: do shared_ptrs to resized vector remain valid? jomarbueyes@hotmail.com - 2016-02-26 09:00 -0800
Re: do shared_ptrs to resized vector remain valid? Juha Nieminen <nospam@thanks.invalid> - 2016-02-26 18:08 +0000
csiph-web