In fact it's often hard to even figure out what's going on at all. For example, in the MyKlass case.
v.push_back(MyKlass(2, 3.14f));
What's being invoked: a move constructor or copy constructor? How would you verify? You could maybe add a move or copy constructor with some logging, but defining either of those can change which one gets invoked! So I guess you have to hunt through the assembly.Here's another case that terrifies me. Testing with clang 3.5:
return a; // invokes a's move constructor
return true ? a : a; // invokes a's copy constructor
if (true) return a; else return a; // elides constructors using RVO
So even when you do get it right, seemingly irrelevant changes can silently break it. It's so fragile!How do other C++ programmers verify that they're getting this stuff right?