Re:The C++14 Standard: What You Need to Know
by zeroonetwothree on Thursday September 18, 2014 @12:45AM
(#8333730)
This isn't new in C++14 though.
Re:The C++14 Standard: What You Need to Know
by MichaelMoser123 on Thursday September 18, 2014 @02:04AM
(#8333943)
lambda functions and the auto keyword aren't new either - in C++11 already.
Re:The C++14 Standard: What You Need to Know
by capisce on Thursday September 18, 2014 @03:34AM
(#8334140)
Yes, but the use of auto to auto-deduce the return type is new in C++14, as well as the use of auto as a return type for lambdas to produce generic lambdas - generic functions without having to use template syntax.
Re:The C++14 Standard: What You Need to Know
by ternaryoperator on Thursday September 18, 2014 @02:56AM
(#8334053)
auto keyword was in C++11, but as this article points out, it does a whole lot more in C++14.
here is an explanation http://stackoverflow.com/questions/6815685/move-semantics-wh...
it is supposed to save extra copies like here
string a("a"); string b("b");
string c = a + b; // creates temporary object that is copied into C by value - the temporary is just a 'full copy'; so that for the temporary it needs an extra allocation and strcpy and free.
the fix is to add the following to the string class
string(string &&r) { ... }
string &operator=(string &&r) { ... }
so the operator with the && receives and 'rvalue' reference - which is a special reference to just this temprorary and the implementation of this is supposed to swap the data of the temporary with that of the this object; the temporary is then discarded.