Re: [boost] Re: Re: Boost Array Initialization Technique

In-Reply-To: <d7iigr$7tn$1@sea.gmane.org> technews@kangaroologic.com (Jonathan Turkanis) wrote (abridged):
boost::array is just supposed to give built-in arrays a container interface. Built-in arrays never have size 0, so I don't see why boost::arrays should.
Surely built-in arrays can have size 0? For example: int n = 0; int *array = new int[n]; In my experience it is important to handle zero edge-cases correctly and uniformly. I have been reading: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1479.html and I don't understand the reasoning there. Personally I'd rather change the language so that: const int n = 0; int array[n]; was acceptable too, making the static case consistent with the dynamic case and both consistent with n>0. Even if this glitch is not fixed (because it requires a language change), I'd rather an array library not perpetuate the problem. For example: array<T,0> a; could allocate a single byte of memory with alignment suitable for T. At worst, sizeof(T) bytes could be allocated, but no T should be constructed. -- Dave Harris, Nottingham, UK.

| -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Dave Harris | Sent: 05 June 2005 15:18 | To: boost@lists.boost.org | Subject: Re: [boost] Re: Re: Boost Array Initialization Technique | | In-Reply-To: <d7iigr$7tn$1@sea.gmane.org> | technews@kangaroologic.com (Jonathan Turkanis) wrote (abridged): | > boost::array is just supposed to give built-in arrays a container | > interface. Built-in arrays never have size 0, so I don't see | > why boost::arrays should. | | Surely built-in arrays can have size 0? For example: | | int n = 0; | int *array = new int[n]; | | In my experience it is important to handle zero edge-cases | correctly and | uniformly. I have been reading: | http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1479.html | | and I don't understand the reasoning there. Personally I'd | rather change | the language so that: | | const int n = 0; | int array[n]; | | was acceptable too, making the static case consistent with | the dynamic | case and both consistent with n>0. I agree with this strongly. And the best way to deal with default initialisation is to remove it completely. A recent 'quiz' of the UK BSI C++ panel reveal that it is so confusing that even above averagely 'experts' often get it wrong - or fail to agree what the right answer is!) This is a big language change, but a vital one IMO. Paul Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539 561830 +44 7714 330204 mailto: pbristow@hetp.u-net.com
participants (2)
-
brangdon@cix.compulink.co.uk
-
Paul A Bristow