Boost logo

Boost :

Subject: Re: [boost] Interest in a 'Boost.property' library?
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2013-07-07 14:29:31


07.07.2013 21:40, Andrey Semashev:

> I must say I'm not sure I see the point of x. You already had to define
> set_x/get_x, so you already concealed the nature of the property x (which is
> why properties exist, right?).

I think properties exists for following reasons:
1) setter/getter have access to enveloping object internals
2) usual access syntax to field (i.e. "=") at user side
3) setter and getter are "tied" by syntax
4) virtual getter/setter, i.e. behaviour should be overridable by
derived classes.
(though, I may be wrong - I never use them)

> One additional downside I see is that you have to store this inside the
> property, which adds to the vec2 object size

Maybe property-wrapper can be constructed on-demand, not affecting
object size, like:

widget.prop() = x;
cout << widget.prop();

It only affects 2) from list above. Though it can be critical, and maybe
in that case rollback to member functions is preferred:

widget.prop(x);
cout << widget.prop();

-- 
Evgeny Panasyuk

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