1 May 2003 13:32
Re: Re: const shared_ptr<>
Hossein Haeri <powerprogman <at> yahoo.com>
2003-05-01 11:32:05 GMT
2003-05-01 11:32:05 GMT
Dear John, > I'd say you could call any of the 'const' member > functions (e.g. > operator*(), operator->(), get(),...,etc), but the > returned type is a > non-const pointer. > > Since operator*() is a const member function, it is > legal on a const > shared_ptr<T>. The '=', then, applies to the > non-const shared ptr > returned, not to the shared_ptr<T> object, itself. I can't understand! Can you please describe your idea more? Do you mean that calling a non-const member function for shared_ptr<T> will result in acting the desired operatio on a temporal mutable copy of the original const version? > Note also, that you're supposed to initialized > shared_ptr<T> with a > *dynamically* allocated T (use new), because it will > call 'delete' on > the ptr when the last reference disappears. So you > are wrong to > initialize it with the address of a stack variable. Thank you very much because of recalling that to me. But a subtle point here is that the asserion you made(Continue reading)

RSS Feed