I have a class with an array of scoped pointers to objects which do NOT have a default constructor.
The only way I've found to "initialise" them is using swap()
like this:
class Bar {
Bar(char * message) {};
}
class Foo
{
boost::scoped_ptr<Bar> arr[2];
Foo()
{
arr[0].swap(boost::scoped_ptr<Bar>( new Bar("ABC") ));
arr[1].swap(boost::scoped_ptr<Bar>( new Bar("DEF") ));
};
}
This feels a little verbose and clunky. Have I missed a smarter way of doing it?