views:

35

answers:

1

Usually like this:

#include <boost/assign/std/vector.hpp>
vector<int> v;
v += 1,2,3,4,5;

Except for a:

#include <boost/ptr_container/ptr_vector.hpp>
boost::ptr_vector<int> v;

If you need to know the reason; I'm using ptr_vector instead of vector only so I don't have to delete elements, but I need to initialize it using Boost.Assign as I want the ptr_vector to be const (can't use push_back() or pop_back() anywhere else in code.)

Thanks in advance for you answers, it's possible I'm using the wrong container type?

+2  A: 

Use Boost.Assigns ptr_list_of():

#include <boost/assign/ptr_list_of.hpp>

// ...
const boost::ptr_vector<int> pv = boost::assign::ptr_list_of<int>(1)(2)(3);
Georg Fritzsche