I am curious to how data is handled in the situation:
chapterlist.clear();
cScene newscene;
newscene.name = "Laura does something.";
newscene.words = 432;
newscene.pov = "Laura";
cChapter newchapter;
newchapter.scenelist.push_back(newscene);
chapterlist.push_back(newchapter);
chapterlist is a cChapter vector.
I am creating a new cScene object, and pushing it onto the scenelist vector of a new cChapter object, which I then push onto chapterlist.
My question is: when I am pushing objects onto a vector, is all the data being duplicated into the vector, while the old data is destroyed from the stack when the scope ends?
Or is something else happening???
PS: I hate pointers, as do many.
The C++ standard states in chapter 23, Containers library that
a.push_back(x)has the operational semantica.insert(a.end(), x). It is furthermore stated thata.insert(p, t)inserts a copy of t before p.So yes, a copy is inserted into the vector.