I have a situation where profiling has shown that a large structure is taking a significant time to be copied:
std::vector<LargeStruct> allOutputs;
std::vector<LargeStruct> thisOutput(getResultOfOperation());
// catenate results to allOutputs
std::copy(thisOutput.begin(), thisOutput.end(), std::back_inserter(allOutputs));
My first instinct was to try changing copy
to move
:
std::move(thisOutput.begin(), thisOutput.end(), std::back_inserter(allOutputs));
However this didn't yield any performance increase, presumably because one of the members of LargeStruct doesn't have a move constructor/assignment operator.
The question is: how can I diagnose this to find out which member is causing the problem?
EDIT:
Does std::is_move_constructible help in this case? It sounds from this post that it doesn't