Article View: comp.std.c++
Article #4103auto_ptr problem?: delete or delete[]
From: Nico Josuttis
Date: Thu, 18 Apr 1996 16:42
Date: Thu, 18 Apr 1996 16:42
28 lines
1822 bytes
1822 bytes
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?
Isn't it a BIG design problem ?
Reading the DWP it calls delete (without [])
what would be wrong in many cases since
using new for arrays is probaly made very often.
I fear we need two kind of auto_ptr, don't we?
--
Nico address: BREDEX GmbH, Nicolai Josuttis
email: nico@bredex.de Fallersleber-Tor-Wall 23
phone: +49 531 24330-0 D-38100 Braunschweig
fax: +49 531 24330-99 Germany
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<199604181455.QAA12877@bredex.bredex.de>Path:
arc1-ca.pugleaf.net!fido.asd.sgi.com!austernShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern From: Nico Josuttis <nico@bredex.de> Newsgroups: comp.std.c++ Subject: auto_ptr problem?: delete or delete[] Date: 18 Apr 1996 09:42:52 PDT Organization: Bredex GmbH Approved: austern@isolde.mti.sgi.com Message-ID: <199604181455.QAA12877@bredex.bredex.de> Reply-To: nico@bredex.de NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: Thu, 18 Apr 1996 16:55:50 +0200 Apparently-To: nico@bredex.de Apparently-To: std-c++@ncar.ucar.edu X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMXZxDUy4NqrwXLNJAQFj1QH+OGwGfE3GnP/7f5oSYvvxMGOq68Nsnd7M JzqWzGKAWA9n72mc5D3pySUp5x0eQpqT3ik5/rmqgLQrhooJ0Qfhdg== =U6dR Originator: austern@isolde.mti.sgi.com