Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does && mean with a parameter type in C++? [duplicate]

Possible Duplicate:
What does T&& mean in C++0x?

I had never seen a double ampersand before I read this answer.

The code snippet in question is this:

template <typename T>
T& as_lvalue(T&& x)
{
    return x;
}

What does && achieve? What sorts of parameters can be passed to as_lvalue()

like image 245
paperjam Avatar asked Dec 07 '11 23:12

paperjam


1 Answers

It is called an rvalue reference, and it is new in C++11. It binds to temporaries without making a copy.

like image 123
Remy Lebeau Avatar answered Oct 13 '22 21:10

Remy Lebeau