Boost logo

Boost :

From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2006-08-08 18:58:03

Sylvain Pion wrote:

> I would like to use boost::array as a class data member.
> This raises a problem when constructing it in the
> initialization list of the class members:
> class A {
> boost::array<int, 3> a;
> A()
> : a(???) {} // what do I write here ???
> };
> Is there a way to construct the data member efficiently?
> By efficiently, I mean using copy constructors instead of
> default constructors followed by assignments of array elements.

This is not possible with the language today.
Hopefully, there will be changes in the next version of the language
that make this sort of initialization possible. There are certainly
several proposals before the committee.

The key problem is that you cannot supply user-declared constructors
for aggregate classes, and we rely on array being an aggregate for
brace initialization. Likewise, you can't use brace initialization in
a constructor initializer list.

I should probaby add a small FAQ to the array docs to describe these


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