Please consider the following piece of code
class A
{
public:
A(std::size_t d)
: m_v(d)
std::vector<double> operator()() {
return m_v;
}
private:
std::vector<double> m_v;
};
I want to move m_v
to the caller of operator()
instead of copying it. What do I need to do? Simply write return std::move(m_v)
and change the return type to std::vector<double>&&
?
It is enough to write return std::move(m_v)
.