I want to push vectors into my queue using the following code:
queue<vector<int>> q;
for(int i=0;i<10;i++) {
vector<int> t(3,-1);
q.push(t);
}
vector<int> p = q.front();
q.pop();
Is this correct? I'm worried that since t is only defined inside the loop it will get destroyed as soon the loop is over. So will the pushed vectors still exist in the queue after the loop is over?
I had a similar code which was giving segmentation fault, so I thought this might be the problem.