# What is the impact of C++11 move semantics in the context of scientific computing?

C++11 introduces move semantics which can, for example, improve code performance in situations where C++03 would need to perform a copy construction or copy assignment. This article reports that following code experiences a 5x speed up when compiled with C+11:

vector<vector<int> > V;
for(int k = 0; k < 100000; ++k) {
vector<int> x(1000);
V.push_back(x);
}


What is the impact of C++11 move semantics in the context of scientific computing?

I'm interested in this question is general but more specifically I'm also interested in move semantics for Finite Element codes written using boost libraries. I tested some of my own C++03 code using boost version 1.47.0 (since boost release notes mention move semantics are introduced in 1.48.0) and boost version 1.53.0, but I didn't notice much improvement. I guess any savings from not having to do copy-construction for boost::numeric::ublas::vector/matrix and boost::function are not noticeable since solving system matrices constitutes the bulk of the workload.

Edit: Actually it looks like move semantics are only implemented for boost::function (see version 1.52.0 release notes). There is no mention of move semantics in boost::numeric, I grepped the sources to make sure and there seem to be no rvalue references.

• As you note in the last part of your question, unless you've profiled your code and seen a lot of copying going on, you cannot substantially improve your performance by using move semantics. – Bill Barth Apr 9 '13 at 16:16