Created on 1999-02-17.00:00:00 last changed 171 months ago
Proposed resolution:
In [meta.unary], paragraph 2, move the auto_ptr_ref definition to namespace scope.
In [meta.unary], paragraph 2, add a public assignment operator to the auto_ptr definition:
auto_ptr& operator=(auto_ptr_ref<X> r) throw();
Also add the assignment operator to [meta.unary.prop]:
auto_ptr& operator=(auto_ptr_ref<X> r) throw()Effects: Calls reset(p.release()) for the auto_ptr p that r holds a reference to.
Returns: *this.
There are two problems with the current auto_ptr wording in the standard:
First, the auto_ptr_ref definition cannot be nested because auto_ptr<Derived>::auto_ptr_ref is unrelated to auto_ptr<Base>::auto_ptr_ref. Also submitted by Nathan Myers, with the same proposed resolution.
Second, there is no auto_ptr assignment operator taking an auto_ptr_ref argument.
I have discussed these problems with my proposal coauthor, Bill Gibbons, and with some compiler and library implementors, and we believe that these problems are not desired or desirable implications of the standard.
25 Aug 1999: The proposed resolution now reflects changes suggested by Dave Abrahams, with Greg Colvin's concurrence; 1) changed "assignment operator" to "public assignment operator", 2) changed effects to specify use of release(), 3) made the conversion to auto_ptr_ref const.
2 Feb 2000: Lisa Lippincott comments: [The resolution of] this issue states that the conversion from auto_ptr to auto_ptr_ref should be const. This is not acceptable, because it would allow initialization and assignment from _any_ const auto_ptr! It also introduces an implementation difficulty in writing this conversion function -- namely, somewhere along the line, a const_cast will be necessary to remove that const so that release() may be called. This may result in undefined behavior [7.1.5.1/4]. The conversion operator does not have to be const, because a non-const implicit object parameter may be bound to an rvalue [13.3.3.1.4/3] [13.3.1/5].
Tokyo: The LWG removed the following from the proposed resolution:
In [meta.unary], paragraph 2, and [meta.unary.prop], paragraph 2, make the conversion to auto_ptr_ref const:
template<class Y> operator auto_ptr_ref<Y>() const throw();
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg1382 |
1999-02-17 00:00:00 | admin | create |