
christopher diggins wrote:
----- Original Message ----- From: "Neal Becker" <ndbecker2@gmail.com> To: <boost@lists.boost.org> 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.
I still disagree. Depending on default initialization is like depending on init of static variables to 0. If you really need a special init value, be explicit and say so. I see no logic to the default construct of complex to have 0 value. The only logic to default construct values I can see is where there truly is a sensible default for a parameter.