
10 Aug
2006
10 Aug
'06
7:59 a.m.
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