Binding temporary to a lvalue reference

后端 未结 5 1502
清酒与你
清酒与你 2020-12-06 12:15

I have the following code

string three()
{
    return \"three\";
}

void mutate(string& ref)
{
}

int main()
{
    mutate(three()); 
    return 0;
}
         


        
5条回答
  •  粉色の甜心
    2020-12-06 12:26

    It is VC++'s evil extension. If You oompile with /W4 then the compiler will warn you. I guess you are reading the Rvalue References: C++0x Features in VC10, Part 2. This article had also mentioned that issue.

提交回复
热议问题