Boost logo

Boost :

From: Sylvain Pion (Sylvain.Pion_at_[hidden])
Date: 2006-08-10 03:14:27

Thorsten Ottosen wrote:
> Sylvain Pion <Sylvain.Pion <at>> writes:
>>Jeff Flinn wrote:
>>>Would not the boost.assign library work here?
>>>>>class A {
>>>>> boost::array<int, 3> a;
>>>>> A() : a(boost::assign::list_of(1)(2)(3)(4)) {}
>>>I don't think I've tried it this way yet.
>>It works, but it's not efficient. It is even incredibly worse that
>>doing the assignments by hand (boost 1.33.1 is better than 1.32 though).
>>See my attached test program. Here is what I get (with g++ 4.1):
> Try throwing this into the mix:
> a(boost::assign::cref_list_of<3>(1)(2)(3))

It gives the same result as the "assignment by hand", so it's still not

> It would be nice to see what other compiler give back. Also, do you
> have full optimization turned on?

Optimizing or not does not change anything for the g++ I tested.

> That said, list_of() is never going to compete with direct aggregrate
> initialization.

My point about introducing make_array() was also about syntax.
The various Boost.Assign variants have poor syntax, imho, even
if they could be optimized (I haven't looked at their implementation).

I agree that the best thing would be to have a change in the language.
But in the mean time, I think introducing make_array() in Boost.Array
would be nice. I did not get feedback on that.


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