Angus Leeming <[EMAIL PROTECTED]> writes: | On Thursday 01 August 2002 12:53 pm, Lars Gullik Bjønnes wrote: > | It appears you aren't against the basic idea. Good. > >> | I'd like, therefore, to change the LyXView store >> | public: >> | /// return the current buffer view >> | BufferView * view() const { return bufferview_,get(); } >> >> I'd rather change this one to >> >> a. return a shared_ptr >> b. return a weak_ptr > | Then I think it should be | boost::shared_ptr<BufferView> const & view() const { return bufferview_; } > | No more expensive than before, but may lead to more extensive changes to the | rest of the code base than I'd anticipated. > >> | and to make it accessible through BufferView: >> | boost::weak_ptr<BufferView> const BufferView::cachablePtr() const >> | { >> | return pimpl_->owner_->cachablePtr(); >> | } >> >> and you really need this? > | Yes. Only now it would be > | boost::shared_ptr<BufferView> const & BufferView::cachablePtr() const | { | return pimpl_->owner_->view(); | } > | Think of all those times when a BufferView * (or even a BufferView &) is | passed to an inset. It makes no sense at all to pass a shared_ptr in these | cases, but if the inset wants to cache this BufferView * then it can do so as
This is where we disagree... it think it makes perfect sense to _always_ pass a shared_ptr. And if the caller needs to cache the BufferView it should do that with a weak_ptr. (And when using it could be turned back into a shared_ptr if needed.) -- Lgb