Re: [boost] [optional] generates unnessesary code for trivial types

10 Feb
2012
10 Feb
'12
8:10 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?
Apologies, I meant to say int i = 1; int j = 2; optional<int&> oi = i; optional<int&> oj = j; oi = oj; Boost.Optional documentation explains it better: http://www.boost.org/doc/libs/1_48_0/libs/optional/doc/html/boost_optional/r... Regards, &rzej
4872
Age (days ago)
4872
Last active (days ago)
0 comments
1 participants
participants (1)
-
Andrzej Krzemienski