🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2287

allocating memory with 'T::operator new[]'

#2287
From: Dietmar Kuehl
Date: Mon, 23 Oct 1995 21:31
27 lines
2087 bytes
Hi,

is it possible to always allocate memory using 'T::operator new[]' even
if this operator is not defined for 'T' (in which case '::operator
new[]' is called)? ... and, of cource, the inverse with 'T::operator
delete[]'.

The problem where this would be handy is the following: An array
template class (with template parameter 'T') which does not use
built-in arrays to represent the array. The memory has to be allocated
somehow with 'operator new[](size)'. But this call would call
'::operator new[](size)', even if 'T::operator new[](...)' exists,
because there is no way to figure out that the memory used for 'T's. On
the other hand it would be logical to use 'T::operator new[](...)' to
allocate the memory. However, if it is not possible to allocate memory
with 'T::operator new[](size)' even if 'operator new[](size)' is not
defined for 'T' (or a base class), there would be no way to write this
template class such that always the correct new operator is called.
The same argumentation can be applied to 'operator delete[](...)'.
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl
I am a realistic optimist - that's why I appear to be slightly pessimistic

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <46h003$e83@eurybia.rz.uni-konstanz.de>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: kuehl@uzwil.rz.uni-konstanz.de (Dietmar Kuehl)
Newsgroups: comp.std.c++
Subject: allocating memory with 'T::operator new[]'
Date: 23 Oct 1995 21:31:41 GMT
Organization: Fakultdt f|r Mathematik und Informatik
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <46h003$e83@eurybia.rz.uni-konstanz.de>
Reply-To: Dietmar.Kuehl@uni-konstanz.de
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
Keywords: memory new delete
X-Nntp-Posting-Host: uzwil.informatik.uni-konstanz.de
X-Newsreader: TIN [version 1.1 PL6]
Content-Length: 1195
X-Lines: 23
Originator: clamage@taumet