mardi 10 mars 2015

vector of unique_ptr: how to access

I have a vector of unique_ptr used like the following:



void f2(const T *val);

void f(vector<unique_ptr<T> *vec)
{
f2(vec->at(0).get());
}


But after f2() call, I found that the first element of vec is null. So that means that vec->at(0) gets it moved?


If so, what is the proper way to access the individual element of such vector?


Aucun commentaire:

Enregistrer un commentaire