Boost logo

Boost :

From: Hamish Mackenzie (boost_at_[hidden])
Date: 2002-02-18 16:03:32

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

> Secondly, you're talking about VC6, running on Windows, right?
> Machines on Windows (or actually, machines on anything) are
> loaded with memory. Well, at least in such a way that it
> doesn't matter whether an application uses 1Mb or 10Mb of
> memory. If it does, I suggest buying some memory because
> there's far worse out there than properties.

Yeah but my Zaurus only has 24MB RAM and a lot of that is used up once I
run samba and openssh :-)

Hamish Mackenzie

Boost list run by bdawes at, gregod at, cpdaniel at, john at