mercredi 6 juin 2018

How to use C++11 std::move semantics. I tried writing code, the output I get is some thing different

#include <iostream>
#include<vector>

using namespace std;
int function(int &&p)
{
    cout<<"function:"<<p<<endl;

    return 0;
}
int main()
{

    int a =10;
    function(std::move(a));
    cout<<"main:"<<a<<endl;


    return 0;
}

The output I get is as below. function:10 main:10

But shouldn't it be as below? function:10 main:

Aucun commentaire:

Enregistrer un commentaire