This is not a reference to a reference; there is no such thing.
What you're seeing is a C++0x rvalue reference, denoted by double ampersands, &&
. It means that the argument i
to the function is a temporary, so the function is allowed to clobber its data without causing problems in the calling code.
Example:
void function(int &i); // A
void function(int &&i); // B
int foo();
int main() {
int x = foo();
function(x); // calls A
function(foo()); // calls B, because the return value is a temporary
}
This rarely useful with plain int
s, but very useful when defining move constructors, for example. A move constructor is like a copy constructor, except that it can safely 'steal' the internal data from the original object, because it's a temporary that will cease to exist after the move constructor returns.