From 6655623425548406437
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8366734ec6aad121
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-14 08:38:19 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!swrinde!ihnp4.ucsd.edu!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: new foo[0]
Message-ID: <9416600.27801@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <CquD6C.LEK@lehman.com> <1994Jun6.152021.20287@cs.wm.edu> <JASON.94Jun6201445@deneb.cygnus.com> <2tk0dq$6ej@hpsystem1.informatik.tu-muenchen.de>
Date: Tue, 14 Jun 1994 14:40:41 GMT
Lines: 29

schuenem@Informatik.TU-Muenchen.DE (Ulf Schuenemann) writes:

>To implement the delete[]-operator new[] must store information about
>size of the array somewhere (Is there a way to do without it?).
>I would appreciate if there were a STANDARD for obtaining this
>information at runtime (with a new keyword - oh, how ugly. I'll
>call it XXX here):

I agree that this would be a good idea, but it shouldn't be
a new keyword, it should be a library function.

>With pa being a kind of reference(pointer) to an array:
>
>	XXX(pa)
>
>returns the number of elements in the array refered to by pa.
>To work in C++ pa must not be a pointer to an element (single object
>or somewhere in an array), but a refenence to (the beginning of)
>an array.

Nah, just make `pa' a pointer and require that it point to the
first element of an array allocated using new[], otherwise the
behaviour is undefined.

	template <class T>
	size_t dynamic_array_size(T* pointer_to_first_element);

-- 
Fergus Henderson - fjh@munta.cs.mu.oz.au


