Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-03-04 11:32:24

"David Turner" <dkturner_at_[hidden]> writes:

> Hi
> Dave Abrahams wrote:
>> "David Turner" <dkturner_at_[hidden]> writes:
>>>> Hm...maybe I don't understand why it has to be that way?
>>> [snip]
>>>> why can't we say
>>>> window w;
>>>> w.add( button( "Click me" ) ); (*)
>>> As I explained in an earlier post to Peter Dimov, there are technical
>>> reasons why this isn't possible. Widgets have to be rooted in an owning
>>> window, and it's not possible to transfer widgets from one window to
>>> another. Therefore, button has to take an owner-window parameter in its
>>> constructor.
>> button("click me") doesn't have to be a widget. Think expression
>> templates. It can just build up a type to be used by window to add a
>> button.
> Interesting. But could this be done in such a way that
> button b("click me");
> w.add(b);
> is also acceptable?

Sure, though I would never call the function "add". I'd be looking
for declarative DSELs like:

    window("Warning: now entering twilight zone")
        text_field("my favorite color is:"),
        button("OK") | button("cancel")


Dave Abrahams
Boost Consulting

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