Boost logo

Boost Users :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2007-05-25 20:14:34


Use ptr_vector<ptr_vector<T> >

On 5/25/07, Seweryn Habdank-Wojewódzki <shw_at_[hidden]> wrote:
> Hi!
>
> Can anyone tell me why std::vector < boost::ptr_vector < T > > can not be
> reserved and resized I can not push_back anything inside vector, due to
> compile errors?
>
> I am using ptr_vector for storing copyable, but nonassignable objects of type
> T - in fact objects contains mainly const elements.
>
> Regards.
>
> #include <iostream>
> #include <vector>
> #include <boost/ptr_container/ptr_vector.hpp>
>
> class Foo
> {
> public:
> Foo ( int const i, int const & j )
> :i_(i), j_(j)
> {}
>
> Foo ( Foo const & f )
> : i_(f.i_), j_(f.j_)
> {}
>
> private:
> int const i_;
> int const & j_;
> void operator= ( Foo const & f );
> };
>
> int main()
> {
> using namespace std;
> using namespace boost;
>
> int k = 10;
> ptr_vector<Foo> g;
>
> g.push_back ( new Foo(1,k) );
>
> vector<ptr_vector<Foo> > d;
> //d.push_back ( g ); <-- Errors
> //d.resize(5)
> //d.reserve(5)
> }
>
> --
>
> |\/\/| Seweryn Habdank-Wojewódzki
> \/\/
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
Felipe Magno de Almeida

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