C ++ ampersand '&' at the end of a member function declaration

Sorry, I could not come with a better name.

What does the last ampersand & mean in the following code snippet:

 A & A::operator=(A rhs) & { swap(*this, rhs); return *this; } 

Depending on the answer, I would like to know if:

  • it only makes sense for operator= or can be applied to any function
  • is it a new C ++ 11 feature or does it already exist in C ++ 98/03

If you need more context, I found this syntax here: stack overflow

There is a small explanation, but I do not understand.

Edit (formatting and short answer to my questions):

  • this does not apply to operator=
  • this is a new C ++ 11 feature needed due to new rvalues
+6
source share

All Articles