|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2000-11-14 11:32:12
----- Original Message -----
From: "Martin Schürch" <mschuerch_at_[hidden]>
> Hi
> I have looked at the implementation off auto_restore<>.
> I don't know what was disussed about this before. But perhaps this was
> not mentioned yet:
> After reading the article "Generic<Programming>: Change the Way You
> Write Exception -Safe Code Forever" of Andrei Alexandrescu, I
> implemented auto_restore with the trick, where a reference to a
> temporary instance is stored.
Wow; this is really cute! A different kind of compile-time polymorphism; I
love it.
For those that didn't catch it: you can bind a reference to the base class
of a temporary return value and the temporary still gets destroyed properly
(as its full type) at the end of the scope, even if it doesn't have a
virtual destructor.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk