Article View: comp.std.c++
Article #1573Re: are zero lengthed arrays allowed?
From: jimad
Date: Thu, 03 Aug 1995 18:44
Date: Thu, 03 Aug 1995 18:44
19 lines
1425 bytes
1425 bytes
In C++ zero lengthed arrays are perfectly reasonable and sensible things. C++ supports dynamically allocated zero-lengthed arrays, but not statically allocated zero-lengthed arrays. In the context of templated classes this makes little sense, IMHO. Consider a templated class using a default buffer, that can be dynamically grown. The size of the default buffer is a template parameter. Zero is a perfectly reasonable size. When the zero length default buffer is filled, then it is dynamically grown. The one-past the end pointer makes perfect sense here. Let's say in the above templated case an end of buffer ptr is kept to signal buffer full. In the zero-length buffer case the one-past the end ptr becomes identical to the head of buffer ptr, buffer full condition is signaled immediately, a larger dynamically allocated buffer is allocated, and every thing works perfectly. Assuming zero length statically allocated buffers were allowed.
Technical Details
Message-ID:
<3vr5ee$ck0@rednews01.microsoft.com>Path:
arc1-ca.pugleaf.net!news.microsoft.com!newsReferences:
<1995Jul26.032716.22158@sq.sq.com> <3v6qt2$sk3@newsbf02.news.aol.com> <DCIIHw.97u@agora.rdrop.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.microsoft.com!news From: jimad@microsoft.com (jimad) Newsgroups: comp.std.c++ Subject: Re: are zero lengthed arrays allowed? Date: 3 Aug 1995 18:44:30 GMT Organization: Microsoft Corporation Message-ID: <3vr5ee$ck0@rednews01.microsoft.com> References: <1995Jul26.032716.22158@sq.sq.com> <3v6qt2$sk3@newsbf02.news.aol.com> <DCIIHw.97u@agora.rdrop.com> NNTP-Posting-Host: 157.56.137.22 Mime-Version: 1.0 X-Newsreader: WinVN 0.93.14