Topic: Why operator [] is not provided for auto_ptr in the standard C++
Author: "John Hickin" <hickin@nortel.ca>
Date: 1997/01/13 Raw View
>The user has to know what's an auto_ptr in order to use it.
>I don't think the argument is very powerfull.
I can agree in general but I feel that the case of 'delete ptr'
must be viewed as an exception worth preventing because delete
is such a frequent operation (especially compared to directly
invoking a destructor as in ptr.~auto_ptr<Foo>().
Your 'char a[5]; delete [] a; ' example is precisely what lead me
to an alternative solution to the auto_ptr delete problem. After
investigating why the compiler should consider the code legal it
became evident that adding (a private) operator void*() to auto_ptr
would be sufficient. I have not proposed this alternative solution
because it is too late to make it into the standard. In addition
I havn't had the time to investigate all the ramifications of the
the idea.
--
John Hickin Nortel Technology, Montreal, Quebec
(514) 765-7924 hickin@nortel.ca
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]