Cannot access structure elements using iterator to list containing shared_ptr<struct>

Hi,
I would like to have a list(STL) of shared_ptr. The shared_ptr would hold the pointer to the structure "packet_holder" .
struct packet {
int c; union{ struct pkt_header header; struct ip_header ip_hd; }type;
}packet_holder;
list<boost::shared_ptr<packet_holder> > pkt_list;
boost::shared_ptr<packet_holder> pkt(new packet_holder); pkt_list.push_pack(pkt);
Having defined this, I would like to use iterator to iterate through the list. list<boost::shared_ptr<packet_holder> >::iterator it; for(it = list.begin();it != list.end();it++) But I am not able to access the inner details of the struct "packet_holder" using the iterator. it->type.header is not accessible.
Can anyone please suggest me where exactly I might be wrong.
--
With Regards, Manjunath BJ
-- With Regards, Manjunath BJ
-- With Regards, Manjunath BJ

But I am not able to access the inner details of the struct
"packet_holder" using the iterator. it->type.header is not accessible.
Changing this to (*it)->type.header should help -- View this message in context: http://boost.2283326.n4.nabble.com/Cannot-access-structure-elements-using-it... Sent from the Boost - Dev mailing list archive at Nabble.com.

Thank you. Yes. Your suggesstion helped me. I had to dereference the iterator to access the shared_ptr. On Thu, Jun 14, 2012 at 10:57 AM, prasad <pras.som@gmail.com> wrote:
But I am not able to access the inner details of the struct
"packet_holder" using the iterator. it->type.header is not accessible.
Changing this to (*it)->type.header should help
-- View this message in context: http://boost.2283326.n4.nabble.com/Cannot-access-structure-elements-using-it... Sent from the Boost - Dev mailing list archive at Nabble.com.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- With Regards, Manjunath BJ
participants (2)
-
Manjunath BJ
-
prasad