samedi 26 décembre 2020

Returning constructor arguments in braces?

I am new to C++ and the brace initialization (or uniform init) really is confusing. What exactly happens when a function returns a list of arguments in braces? Thanks a lot for claryfying.

std::vector<double> foo()
{
  return {1, 2}; // is this the same as: std::vector<double>{1, 2} or std::vector<double>(1, 2)? or something else?
}

Aucun commentaire:

Enregistrer un commentaire