E.g.
vector<string> a;
vector<string> b;
a.push_back("first");
b=a;
Would it be optimised somehow as
vector<string> b;
b.push_back("first");
E.g.
vector<string> a;
vector<string> b;
a.push_back("first");
b=a;
Would it be optimised somehow as
vector<string> b;
b.push_back("first");
Short answer: Yes.
Long answer: Not really an "optimization", as most modern compilers (read as: non-MSVC) will do that. It's called static single assignment (SSA) and GCC supports it since version 4.0 - and it kicks ass, too!
Well, you're saving yourself a call to operator=
...
You should always remember the 2 rules of optimization though.
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson