🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Alexander Krotoff Sun, 21 Apr 1996 15:33
Re: auto_ptr problem?: delete or delete[]
#4128
Author: Alexander Krotoff
Date: Sun, 21 Apr 1996 15:33
33 lines
1926 bytes
In article <199604181455.QAA12877@bredex.bredex.de> you wrote:
> In a tutorial a student asked a very good question i think:
> How can auto_ptr imagine which delete to use.
> Consider:
>  int* p = new int;
> and
>  int* p = new int[10];
> should result in different delete operations.
> But if I let auto_ptr do the job, how does it know
> which one to use?

Reading WP I was confused too. Really, we need auto_ptr for array
of objects more often, than auto_ptr for single object. In the last
case we are able to use simple auto object instead of dynamic
allocation and closely link allocated object with the automatic
object (of auto_ptr type).

Yes, I know there are several applications of auto_ptr which cannot
be solved just by auto objects...

Probably somebody from ANSI committee library WG may clean the situation.

--
Alexander N. Krotoff		krotoff@such.srcc.msu.su
Research Computer Center	tel: +7(095)939-2638
Moscow State University		fax: +7(095)939-4430


[ 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                             ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads