Container of shared_ptr's but iterate with raw pointers
        Posted  
        
            by 
                Sean Lynch
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sean Lynch
        
        
        
        Published on 2012-04-05T20:38:58Z
        Indexed on 
            2012/04/05
            23:30 UTC
        
        
        Read the original article
        Hit count: 367
        
I have a class that holds a list containing boost::shared_ptrs to objects of another class.
The class member functions that give access to the elemets in the list return raw pointers. For consistency I'd also like to be able to iterate with raw pointers instead of shared_ptrs. So when I dereference the list iterator, I'd like to get raw pointer, not a shared_ptr.
I assume I need to write a custom iterator for this. Is this correct? If so can someone point me in the right direction - I've never done this before.
© Stack Overflow or respective owner