0

I work with legacy C++ that was originally written to compile with C++98. But, we compile now with C++11 (yay!) and try to use the newer compiler features when putting in new or modifying old code. This is a common thing seen in our code:

MyObj a = doCalc(); // some calculation result
MyObj b = a; // copy a to b before modifying a

My question is this. If I change the above to take advantage of newer object creation techniques, am I making the code perform better? Is there any difference to the compiler? Like this:

MyObj b(a); // is this better for performance?
Stuart
  • 35
  • 4
  • 6
    Your second sample does something different to the first. So asking about performance doesn't make sense. Did you mean `MyObj b(a);`? – juanchopanza Jul 12 '17 at 18:49
  • 2
    And if it is `MyObj b(a);` you could've done that in C++98. – juanchopanza Jul 12 '17 at 18:53
  • Yup, sorry, I mistyped it. I'll fix it. But, I guess you answered my question also. Hmm...I must have misunderstood something in C++98. I thought that wasn't possible prior to 11. – Stuart Jul 12 '17 at 21:36

0 Answers0