Article View: comp.std.c++
Article #4114Check whether object has been allocated on heap
From: Felix I. Wyss
Date: Fri, 19 Apr 1996 15:01
Date: Fri, 19 Apr 1996 15:01
27 lines
1820 bytes
1820 bytes
Hello folks!
I'm sure this question has been asked many times but here is it anyway:
How can I determine whether an object has been instantiated by allocating
heap space ("new") or whether it is global/static/automatic or even a member
of an other object.
In other words: does a particular object have to be destroyed by calling
"delete" or not.
Is there a proper (and portable) way to do determine that or is there a
proposal for the new C++ standard to achieve this functionality?
If not, what's about a function "is_dynamic(x)" (where 'x' is a pointer to
an object) that returns 1 for dynamically allocated objects and 0 in all
other cases.
I often came across situations where this information would have been very
useful.
Thank you for your attention!
Felix (fwyss@linx.co.uk)
---
[ 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 ]
Technical Details
Message-ID:
<199604191448.PAA01868@bowmore.linx.co.uk>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
From: "Felix I. Wyss" <fwyss@linx.co.uk> Message-ID: <199604191448.PAA01868@bowmore.linx.co.uk> X-Original-Date: Fri, 19 Apr 1996 15:46:39 +0100 Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 19 Apr 96 15:01:35 GMT Approved: fjh@cs.mu.oz.au Organization: - Newsgroups: comp.std.c++ X-Sender: fwyss@bowmore X-Mailer: Windows Eudora Light Version 1.5.2 Content-Type: text/plain; charset="us-ascii" Subject: Check whether object has been allocated on heap X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMXeq7eEDnX0m9pzZAQEjvQF9FYZq1hEmYrbxUAJn/oDqtVDybvk4pLbE F9MaXAqiJuj/UUfQl1KzTNpYBp69OJuj =3xYJ