mercredi 26 mai 2021

C++ vector push_back empty braces

I've seen code like

struct A {
  int m;
};

vector<A> vec;
vec.push_back({});

My question is: What's the difference between vec.push_back({}); and vec.push_back(A{})? Why can we omit A in A{}?

Aucun commentaire:

Enregistrer un commentaire