
Hi Dave Abrahams wrote:
"David Turner" <dkturner@telkomsa.net> 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? Regards David Turner