Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-02-18 16:15:26


----- Original Message -----
From: "Hamish Mackenzie" <boost_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, February 18, 2002 6:03 PM
Subject: RE: [boost] Properties implementation available

> On Mon, 2002-02-18 at 09:04, Geurt Vos wrote:
> > My usual answer to this is: So?
> > How many properties will a class have? I'd say if there were
> > more than a few, you're doing something wrong, but lets make
> > it 7 as maximum 'acceptable' number of properties. On all
> > platform I tested the implementation on, a pointer-to-object
> > has a size of 4 bytes. 7 * 4 = 28 bytes per class. You'll need
> > a whole lot of such objects for it to make a difference. True,
> > seven is not worst case, but it's definitely a bad case...
>
> How about the example you used of a coordinate type? If you used it in
> a vector graphics library it would almost double the memory used.
>
> I actually have a similar rectangle class which I used a while back to
> port some code from MFC CRect (which stores top, bottom, left and right)
> to wxWindows WRect (which stores x, y, width and height). It uses
> manually coded proxies and member functions like top() left() bottom()
> and right(). Hmm that's four, eight if you add x, y, width and height
> for consistency between between CRect based version and WRect version
> how about area.
>
> Is there a reason that a function returning a proxy will not do the job?
> It avoids the storage problem and does not need the user to change their
> constructors when they add a property.
>
> The only penalty is that you have to put brackets after the property
> name when you use it. As far as I can tell what you already have would
> not need a lot of modification to work as proxy.
>
> See my previous post
> http://groups.yahoo.com/group/boost/message/25317
>
I forgot to mentioned it, sorry, but this proxy approach looked to me like
the right solution.
I already said that having an extra '()' doesn't botter me, and it does tell
the parent what is the user doing with the property, which was shown to be
the main advantage of using properties.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk