Boost logo

Boost :

From: David Turner (dkturner_at_[hidden])
Date: 2004-03-04 02:40:42


Thorsten wrote:

> "David Turner" <dkturner_at_[hidden]> wrote in message
> [snip]
>> The only real problem with "why not" is that gui widgets have shallow
>> copy
>> semantics.
> And why is that a problem?

Because it's surprising to the user (I think).

More to the point, there is a very real problem with creating popup
windows. Remember that the window acts as a factory for all other
widgets, including popup (child) windows. If I were to use the "why not"
syntax, I would have to pass in the owner window as the first parameter of
the constructor, as in:

window w;
button b(w, "Click here");

Now consider creating a popup window. The natural syntax is:

window w;
window p(w);

But now I've invoked the copy constructor of p, which isn't what I wanted.
 The way to make it work properly is to force new windows to be
constructed with a title:

window w("Example Window");
window p(w, "Popup Window");

This is probably the "best" approach, but it still leaves some room for
user error.

David Turner

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