From -642021968341648771 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,839fa42e97baea86 X-Google-Attributes: gidf78e5,public From: Gabriel Netterdag Subject: Re: Placement new[] Compiler Depenent? Date: 1998/11/20 Message-ID: <3655EC63.A223BF35@hotmail.com>#1/1 X-Deja-AN: 414018714 X-NNTP-Posting-Host: sdu213-76.ppp.algonet.se Content-Transfer-Encoding: 7bit Approved: stephen.clamage@sun.com (comp.std.c++) References: <72v90t$9uq$1@engnews2.Eng.Sun.COM> <36535E69.CB09EC8B@prolifics.com> X-UID: 0000000001 X-Status: $$$T Content-Type: text/plain; charset=us-ascii Organization: Algonet/Tninet Mime-Version: 1.0 NNTP-Posting-Date: 20 Nov 1998 22:20:43 GMT Newsgroups: comp.std.c++ Originator: clamage@taumet Hyman Rosen wrote: > > Really? How about this? > > struct sizer { }; > void *operator new[](size_t b, const sizer &) { throw b; } > > template > size_t > size(size_t n) > { > sizer s; > try { > new(s) T[n]; > } catch (size_t b) { > return b; > } > } This is a nice idea. There is just one little subtle point in the Standard that states that the amount of overhead may vary from one invocation of new to another (5.3.4/12). I doubt that any reasonable implementation would do this, but the wording is still there. Regards //Gabriel [ 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 ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]