#12203 closed Bugs (fixed)

boost::optional<optional<T>&> broken in 1.61.0

Reported by: benzejaa@… Owned by: Fernando Cacciola
Milestone: Boost 1.63.0 Component: optional
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:


With the new specialization for boost::optional<T&>, there's one use case that's broken now...if T is itself an optional, things are broken.

Diving into optional/detail/optional_reference_spec.hpp it looks like there's some boost::enable_if statements disabling this functionality. Presumably these statements are to differentiate from the copy constructors/assignment above (although I'm not sure why some of the other statements are similarly guarded). However "is_no_optional" is too broad of a guard.

Likely something like !boost::is_same<optional<T&>, typename boost::decay<R>::type> would be a better condition...I'll try it out and update with further info.

Attachments (0)

Change History (6)

comment:1 Changed 18 months ago by anonymous

For posterity, here's a reproducer:


int main()
   boost::optional<int> x;
   boost::optional<boost::optional<int>&> y(x); //compile error
   return 0;

comment:2 Changed 18 months ago by benzejaa@…

comment:3 Changed 17 months ago by John Maddock

Component: Noneoptional
Owner: set to Fernando Cacciola

comment:4 Changed 17 months ago by benzejaa@…

Whoops, that patch has a minor typo...hold on, let me generate a fixed one

comment:5 Changed 17 months ago by benzejaa@…

Okay same pull request, fixed typo (apparently github lets me just stealthy push --force behind the scenes and updates my pull request automatically...nice!)

comment:6 Changed 12 months ago by akrzemi1

Milestone: To Be DeterminedBoost 1.63.0
Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Fernando Cacciola.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.