|
Boost : |
From: Moore, Paul (Paul.Moore_at_[hidden])
Date: 2000-03-08 07:42:41
From: Dave Abrahams [mailto:abrahams_at_[hidden]]
> > This relies on the rule that temporaries are destroyed at
> > the end of the full expression where they are created. As far
> > as I can see, this rule means that the example works, but it
> > also means that it's a little fragile in practice.
>
> Why does that rule mean your technique is fragile in practice? I don't
> follow.
Hmm. You're right. Now that the standard exists and says what it does, I
can't think of an example which could give problems. Before temporary
lifetimes were standardised, I seem to recall that destruction at the end of
the block was an option - which would of course produce completely the wrong
results.
Actually, if I embed a print inside another expression, say
func(((MB() << "Calling func"), arg));
then the "full expression" is the function call, so destruction happens
later than I intend. But that's a pathological case, and I have no sympathy
for anyone who tries it :-)
Paul.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk