Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-05-10 10:39:24


Josh Quigley skrev:
> Hello,
>
>
>
> I’m trying to use boost::ptr_vector with constant members, like
>
>
>
> // Excerpt 1
>
> boost::ptr_vector<const int> myVector;
>
> myVector.push_back(new int(5)); //This line fails, see
> comment below
>
> myVector[1] = 7; //This should fail,

I haven't spent time trying to support ptr_container<const T>, so I
don't know if the fix will be easy. I'll put it on my todo list though.

Note that

void foo( const ptr_vector<int>& vec )
{
   vec[1] = 7;
}

fails.

I'm not sure I completely understand your analogy though: shared_ptr<T>
and a ptr_vector<T> are not similar types; the former is a smart
pointer, the latter a container.

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net