Click here to Skip to main content
15,895,667 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: how does copy constructor works with vector::push_back Pin
Nemanja Trifunovic29-Mar-06 8:45
Nemanja Trifunovic29-Mar-06 8:45 
GeneralRe: how does copy constructor works with vector::push_back Pin
Stephen Hewitt29-Mar-06 11:14
Stephen Hewitt29-Mar-06 11:14 
AnswerRe: how does copy constructor works with vector::push_back Pin
Johann Gerell28-Mar-06 15:30
Johann Gerell28-Mar-06 15:30 
GeneralRe: how does copy constructor works with vector::push_back Pin
Ajax9528-Mar-06 17:11
Ajax9528-Mar-06 17:11 
GeneralRe: how does copy constructor works with vector::push_back Pin
Stephen Hewitt28-Mar-06 18:05
Stephen Hewitt28-Mar-06 18:05 
GeneralRe: how does copy constructor works with vector::push_back Pin
Ajax9528-Mar-06 20:06
Ajax9528-Mar-06 20:06 
GeneralRe: how does copy constructor works with vector::push_back Pin
Johann Gerell29-Mar-06 1:22
Johann Gerell29-Mar-06 1:22 
GeneralRe: how does copy constructor works with vector::push_back Pin
Johann Gerell29-Mar-06 1:20
Johann Gerell29-Mar-06 1:20 
Ajax95 wrote:
the container will call its copy constructor to make a copy and put into the container


The compiler, if any, makes the copy ctor call.

Ajax95 wrote:
Based on the result of my testing, looks like there are more than one copy of the object is created by copy constructor during the "push_back" process


Not strange at all. The documented fact for a container with value semantics is that a copy of an element is added. It's not stipulated that one and only one copy will be made during the process and that that single copy is the one to be added. In fact, if you had taken the time to step into the push_back code while debugging, you would have noticed that lots of temporary copies are created during the process, which ensures that the original data is not tampered with.

Ajax95 wrote:
some of them got deleted


Of course, that's the temporary ones that goes out of scope at each call return.

Ajax95 wrote:
Looks like the insertion process is more complicated than just a value semantic.


No.

--
The Blog: Bits and Pieces
AnswerRe: how does copy constructor works with vector::push_back Pin
Arvind Bharti30-Mar-06 15:54
Arvind Bharti30-Mar-06 15:54 
Questionatl com error Pin
_tasleem28-Mar-06 2:58
_tasleem28-Mar-06 2:58 
AnswerRe: atl com error Pin
toxcct28-Mar-06 3:05
toxcct28-Mar-06 3:05 
QuestionATL classes Pin
_tasleem27-Mar-06 23:58
_tasleem27-Mar-06 23:58 
AnswerRe: ATL classes Pin
toxcct28-Mar-06 0:36
toxcct28-Mar-06 0:36 
Questionatl+mfc Pin
_tasleem27-Mar-06 22:40
_tasleem27-Mar-06 22:40 
AnswerRe: atl+mfc Pin
toxcct27-Mar-06 23:11
toxcct27-Mar-06 23:11 
GeneralRe: atl+mfc Pin
_tasleem27-Mar-06 23:53
_tasleem27-Mar-06 23:53 
GeneralRe: atl+mfc Pin
toxcct28-Mar-06 0:34
toxcct28-Mar-06 0:34 
GeneralRe: atl+mfc Pin
_tasleem28-Mar-06 2:59
_tasleem28-Mar-06 2:59 
GeneralRe: atl+mfc Pin
toxcct28-Mar-06 3:00
toxcct28-Mar-06 3:00 
Questioninternationalization in ATL/WTL apps Pin
Sidney Chong26-Mar-06 22:40
Sidney Chong26-Mar-06 22:40 
AnswerRe: internationalization in ATL/WTL apps Pin
Michael Dunn27-Mar-06 9:07
sitebuilderMichael Dunn27-Mar-06 9:07 
GeneralRe: internationalization in ATL/WTL apps Pin
Sidney Chong31-Mar-06 23:29
Sidney Chong31-Mar-06 23:29 
GeneralRe: internationalization in ATL/WTL apps Pin
Michael Dunn1-Apr-06 6:01
sitebuilderMichael Dunn1-Apr-06 6:01 
QuestionSTL in DLL problems Pin
jianxin080526-Mar-06 21:31
jianxin080526-Mar-06 21:31 
AnswerRe: STL in DLL problems Pin
khan++27-Mar-06 0:15
khan++27-Mar-06 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.