In this code:
// build string requiring a bunch of processing
std::wstring xmlstr=xml->GetXml();
{
std::lock_guard<std::mutex> guard(my_mutex);
m_deque.push_back(std::move(xmlstr)); // << note the std::move
}
Is it more efficient to use std::move
in this case to reduce making copies?
Is it more efficient to use
std::move
in this case to reduce making copies?
Yes, it is. push_back
has an overload taking rvalue reference which will avoid copying. This is true for any container having push_back
, including std::deque
.