In C++0x, we get an efficiency boost concerning containers with std::move
:
SomeExpensiveType x = /* ... */;
vec.push_back(std::move(x));
But I can't find anything going the other way. What I mean is something like this:
SomeExpensiveType x = vec.back(); // copy!
vec.pop_back(); // argh
This is more frequent (the copy-pop) on adapter's like stack
. Could something like this exist:
SomeExpensiveType x = vec.move_back(); // move and pop
To avoid a copy? And does this already exist? I couldn't find anything like that in n3000.
I have a feeling I'm missing something painfully obvious (like the needlessness of it), so I am prepared for "ru dum". :3