Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-05-31 17:49:38


"christopher diggins" <cdiggins_at_[hidden]> wrote in message
news:007501c56609$1ff361f0$2b792518_at_heronnest...
| ----- Original Message -----
| From: "Allen" <yaozhen_at_[hidden]>
| To: <boost_at_[hidden]>
| Sent: Tuesday, May 31, 2005 1:29 PM
| Subject: [boost] Re: Boost Array Initialization Technique
|
|
| > Did you see the Boost Assign Library:
| >
| > http://www.boost.org/libs/assign/index.html
|
| Yes. However, unless I am mistaken, it can only be used with back-insertable
| containers. There are of course other techniques than the one I proposed. My
| point is that I believe comma initialization to be superior to aggregate
| initialization, and that not making boost:array a conformant reversible
| container to be a mistake.

in the new boost, we might say

array<int,5> a;
a = cref_list_of<5>(1)(2)(3)(4)(5);

if efficiency is important. Missing values are inserted as 0,
and bounds are checked otherwise.

The real benefit is of course when dealing with classes:

struct X
{
    X()
   {}
    X(int, int)
 {}
};

array<X,4> a;
a = list_of<X>(1,1)(1,2)(1,3)(1,4);

-Thorsten


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