Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-01-09 05:23:50


Dan W. wrote:
> Daniel Wallin wrote:
>
> <snip>
> ...
>
>> You can try this example, which does the same thing that your code
>> does, out at:
>>
>> http://www.comeaucomputing.com/tryitout/
>
>
> You're absolutely right. Thanks. Handy link to have.
> I've ended up with something pretty similar to your solution, no more
> inheritance, etc. Now I have a problem: your trick of assigning a
> temporary to a reference on the stack doesn't seem to work on my
> compiler. Is that required to work in the standard?

Yes. At least if:

> struct base {};
>
> struct derived {};
          ^^^^^^^ is derived from base
>
> derived make_temp_derived(){ return derived; }
>
> //scope..
> {
> base const & b = make_temp_derived();
> ...
> } <- the created temporary should last till here?

-- 
Daniel Wallin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk