$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] Cannot access structure elements using iterator to list containing shared_ptr<struct>
From: Manjunath BJ (manjunathbagarey_at_[hidden])
Date: 2012-06-13 10:20:12
>
> 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