Boost logo

Boost Users :

Subject: [Boost-users] ptr_vector<> and vector<shared_ptr<>> compatibility
From: Jan Vogelgesang (jan.vogelgesang_at_[hidden])
Date: 2011-10-11 09:13:01


Hi,

today i had to switch from ptr_vector<MyType> to
vector<shared_ptr<MyType> > (needed weak_ptr's to these elements
somewhere else).
Unfortunately the interfaces of these two containers are quite different
when it comes to element access, e.g., ptr_vector<MyType> returns a
reference to MyType vs. vector<shared_ptr<MyType> >operator[] returns a
reference to a shared_ptr<MyType>.
In my case i had a hard time replacing countless occurrences of
"BOOST_FOREACH(MyType& e, getMyTypeContainerFromSomewhere())".

I'am wondering whats your opinion about a shared_ptr_vector<> that will
comply to a ptr_sequence_adapter, using shared_ptr<> to store the
elements, and including the possibility to get access to the shared_ptr<> ?
Is there any reason why such a container is a bad idea (and thus not
already part of the library)?

greetings
Jan


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