
10 Feb
2012
10 Feb
'12
2:13 a.m.
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