|
Boost : |
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2006-05-25 10:55:20
Paul A Bristow wrote:
> | [mailto:boost-bounces_at_[hidden]] On Behalf Of Thorsten Ottosen
> | > array<int,4> a = list_of(1)(2)(3).to_array( a ); // compiles fine
> | > array<int,4, true> a(1,2,3); // doesn't compile
> |
> | Note that the former zero-initializes the remaining elements.
>
> This is exactly what is NOT wanted.
>
> Although zeros are slightly better than a random not-initialised value, it
> is far, far better to get a compile time message when clearly one meant to
> initialize all the elements.
>
> This is a fundamental mistake in C philosophy IMO.
>
> It you want an array un-initialized, one should have say so very
> specifically.
OK, I see what you mean.
I would be quite easy for me to let
array<int, 5> = cref_list_of<6>(...);
give a compile error if the dimensions did not match.
It can also be done for list_of(), but it is much harder.
Should I put this in the cvs for ref_list_of() and cref_list_of()?
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk