|
Boost : |
From: Sam Saariste (ss_march2001_at_[hidden])
Date: 2006-08-10 03:59:50
> > 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.
The following is possible today and appears to achieve what the OP
asked for (but may not be what the OP wanted):
class A {
static boost::array<int, 3> s_a;
boost::array<int, 3> a;
public:
A() : a(s_a) {}
};
boost::array<int, 3> A::s_a = { 1, 2, 3 };
Sam
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk