[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Re: MVC branch ready to merge back into HEAD.
From:       larsbj () lyx ! org (Lars Gullik Bjønnes)
Date:       2001-02-28 15:01:44
[Download RAW message or body]

Jules Bean <jules@jellybean.co.uk> writes:

| On Wed, Feb 28, 2001 at 11:15:03AM +0000, Angus Leeming wrote:
| > On Wednesday 28 February 2001 09:59, Lars Gullik Bjønnes wrote:
| > 
| > > I don't care if it is "ok", you pass a pointer to the button
| > > controller (or whatever) and delete that pointer in the destructor,
| > > what is not nice. 
| > 
| > Well, I can't disagree with your preferences. Surely though, this is just an 
| > example of a class taking over the management of a pointer?
| 
| Unless you can give it value semantics with a copy constructor.
| 
| Since the button controller is a lightweight object, this may be
| simple enough.
| 
| It doesn't seem to gain a lot, though.

... and if nothing else changes... use a scoped_ptr from boost
insted of the manual delete.

#include <boost/smart_ptr.hpp>

class Foo {
public: 
        Foo(Bar * b) : bc_(b) {}
private:
        scoped_ptr<Foo> bc_;
};


        Lgb





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic