Consider the following snippet:
class Foo {
public:
Foo( int Value );
// other stuff
};
std::list< boost::shared_ptr< Foo > > ListOfFoo = list_of( 1 )( 2 )( 3 )( 4 )( 5 );
This does not work out of the box. What is the simplest way to make this work, or is there any method to assign values to ListOfFoo as simple as that?
boost::assign::ptr_list_oflets you construct a Boost pointer container with a very simple syntax. You can extend it through private inheritance so that it lets you create containers ofshared_ptr:It looks a bit ugly but then it’s really convenient to use: