Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-02-09 21:13:23


> int i = 1;
> int j = 2;
> optional<int&> oi = i;
> optional<int&> oj = j;
> i = j;
>
> The effect here is that i remains 1, j remains 2 and oi and oj both hold a
> reference to j. You may find it less surprising but if you think of
> optional reference as a regular reference that is initialized a bit later,
> the behavior is not what you would expect.

Huh? How does oi come to hold a reference to j?

Regards,
Nate
                                               


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