boostloopsptr-vector

Iterating through boost ptr_vector


I have a ptr_vector list of my own objects. Something like this:

boost::ptr_vector<SomeClass> *list;
list->push_back(new SomeClass()>;
...
BOOST_FOREACH(SomeClass *tempObj, list)   // [x]
{
   tempObj->...
}


>‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type

Solution

  • I think your problem is that you declared 'list' as a pointer to a boost::ptr_vector and are trying to use it as an automatic object.

    IMHO the first line of your code snippet should read:

    boost::ptr_vector<SomeClass> list;