Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-06-01 09:06:36


----- Original Message -----
From: "Neal Becker" <ndbecker2_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, June 01, 2005 8:33 AM
Subject: [boost] Re: Boost Array Initialization Technique

> Loïc Joly wrote:
>
>> AlisdairM a écrit :
>>
>>> Aggregate initialization is an important part of the array concept,
>>> allowing it to act largely as a plug-in replacement for language
>>> arrays, with the bonus it can be passed by value as well as by
>>> reference. The main drawback here is that we cannot deduce the size of
>>> a boost::array, as you can with a language array.
>>
>> From my point of view, the main drawback is that in the following code:
>>
>> vector<double> v1(6);
>> array<double, 6> v2;
>>
>> v1's content is initialized, v2's content is not. In fact, array is
>> about the only class I know of that as a default constructor that does
>> not initialize member data to a legal and documented value. This I
>> strongly dislike.
>>
>> By the way, I also dislike the fact that double d; does not initialize
>> d, but at least people know that fundamental type do not behave well
>> when initialization is concerned.
>>
>
> I strongly disagree. Forcing initialization makes code that is not useful
> for high performance numerical processing. When we declare a container of
> 1000000 elements, we don't want to waste time initializing each, unless we
> want to.

I think the best solution in this case is to use an alternative "collection"
for numerical processing. Using a class intended as general purpose array
for numerical processing I think would not be a good idea.

Christopher Diggins
http://www.cdiggins.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk