This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
Section: 99 [auto.ptr] Status: NAD Submitter: Joseph Gottman Opened: 2000-06-30 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [auto.ptr].
View all issues with NAD status.
According to section 20.4.5, the function auto_ptr::operator=() returns a reference to an auto_ptr. The reason that operator=() usually returns a reference is to facilitate code like
int x,y,z; x = y = z = 1;
However, given analogous code for auto_ptrs,
auto_ptr<int> x, y, z; z.reset(new int(1)); x = y = z;
the result would be that z and y would both be set to NULL, instead of all the auto_ptrs being set to the same value. This makes such cascading assignments useless and counterintuitive for auto_ptrs.
Change auto_ptr::operator=() to return void instead of an auto_ptr reference.
The return value has uses other than cascaded assignments: a user can call an auto_ptr member function, pass the auto_ptr to a function, etc. Removing the return value could break working user code.