Opened 6 years ago

#12973 new Bugs

Example in docs for optional<T&> copy constructor is wrong

Reported by: barry.revzin@… Owned by: Fernando Cacciola
Milestone: To Be Determined Component: optional
Version: Boost 1.63.0 Severity: Cosmetic
Keywords: Cc: barry.revzin@…

Description

In the documentation for Optional in the latest version, and many past versions, the example in the copy constructor for optional<T&> reads:

T v = 2 ; T& ref = v ;
optional<T> init(ref);
assert ( *init == v ) ;

optional<T> init2 ( init ) ;
assert ( *init2 == v ) ;

v = 3 ;

assert ( *init  == 3 ) ;
assert ( *init2 == 3 ) ;

Both init and init2 should be of type optional<T&>, not optional<T>.

Change History (0)

Note: See TracTickets for help on using tickets.