Topic: Comment on Issue 127


Author: scleary@jerviswebb.com
Date: 2000/01/27
Raw View
This is a comment on Open issue #127.

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 behaviour
[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].

I assume this was suggested so that auto_ptr's may be initialized/assigned
from functions returning "const auto_ptr".  I recommend that we declare such
functions a misuse of auto_ptr, since their return value technically cannot
be used.

 -Steve

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]