I normally recommend to use pointers instead of references in such cases, and then you may skip the ugly trick with hidden "operator =" below.