vendredi 24 septembre 2021

Is it possible to initialize new std::vector in one line?

I just wonder if it is possible to new and initialize a std::vector at the same time, something like, do the two things in one line:

std::vector<int>* vec = new std::vector<int>(){3, 4};

instead of, first:

std::vector<int>* vec = new std::vector<int>();

then:

vec->push_back(3);
vec->puch_back(4);

Aucun commentaire:

Enregistrer un commentaire