什么时候应该将std :: move用于内置类型?

时间:2015-03-13 14:18:00

标签: c++ move-semantics

考虑以下代码

#include <iostream>
#include <vector>

int main ()
{
    std::vector<int> myvector;
    int myint;

    std::cout << "Please enter some integers (enter 0 to end):\n";

    do {
        std::cin >> myint;
        myvector.push_back (myint);
    } while (myint);

    std::cout << "myvector stores " << int(myvector.size()) << " numbers.\n";
    return 0;
}

为什么不使用std::vector<int>::push_back(int&&),所以myvector.push_back( std::move(myint) )

0 个答案:

没有答案