Subject: [boost] [optional] Incorrect example
From: Ahmed Charles (ahmedcharles_at_[hidden])
Date: 2011-04-07 17:23:15


http://www.boost.org/doc/libs/1_46_1/libs/optional/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html

int x = 1 ;
int& rx = x ;
optional<int&> ora ;
optional<int&> orb(x) ;
ora = orb ; // now 'ora' is bound to 'x' through 'rx'
*ora = 2 ; // Changes value of 'x' through '
ora'assert(x==2);

Either the comment on the fifth line is wrong or the fourth line
should construct from rx rather than x.