|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-12 09:47:47
Aleksey Gurtovoy wrote:
> How about
>
> function_property< boost::function<bool()> > is_enabled;
>
> or
>
> function_property<bool()> is_enabled;
>
> or even
>
> property<bool()> is_enabled;
FWIW, I went with
inline bool true_ { return true; }
inline bool false_ { return false; }
which allows
is_enabled = true_;
I don't like the word "property", or the property-based style of
programming, in general. :-)
As a side benefit, false_ comes in handy for on_click, too (which is a
function<void()>).
One other observation: keeping a function<> always initialized with the
appropriate default (a variation of the Null Object pattern) leads to much
cleaner code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk