Anarki Anarki - 2 months ago 26
C++ Question

C++ Double Address Operator? (&&)

I am reading STL source codes and I have no idea what && address operator is supposed to do. Here is a code example from stl_vector.h.

vector&
operator=(vector&& __x) // <-- Note double ampersands here
{
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}


Does "Address of Address" make any sense? Why does it have two address operators instead of just one? Thanks.

Answer

This is C++11 code. In C++11, the && token can be used to mean an "rvalue reference".