Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-06-05 09:18:53

In-Reply-To: <d7iigr$7tn$1_at_[hidden]>
technews_at_[hidden] (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:

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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at