|
Boost Users : |
Subject: Re: [Boost-users] boost::shared_ptr with operator[]
From: Igor R (boost.lists_at_[hidden])
Date: 2011-09-26 15:06:58
> I'm using boost::shared_ptr, my class overloads the operator[]. How can I
> access to an element of a shared pointer?
> class myclass {
> Â Â public :
> Â Â Â Â operator[](std::size_t)
> }
> boost::shared_ptr<myclass> x( new myclass );
> How can I get an access to the [] operator? I have tried it with
> (*x)[5] but I'll get a "segmentation fault" error
The syntax is correct.
Ensure that shared_ptr "points" to a valid object, then debug your operator[].
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