Opened 6 years ago
Closed 6 years ago
#12203 closed Bugs (fixed)
boost::optional<optional<T>&> broken in 1.61.0
| Reported by: | Owned by: | Fernando Cacciola | |
|---|---|---|---|
| Milestone: | Boost 1.63.0 | Component: | optional |
| Version: | Boost 1.61.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
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.
Change History (6)
comment:1 by , 6 years ago
comment:3 by , 6 years ago
| Component: | None → optional |
|---|---|
| Owner: | set to |
comment:4 by , 6 years ago
Whoops, that patch has a minor typo...hold on, let me generate a fixed one
comment:5 by , 6 years ago
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 by , 6 years ago
| Milestone: | To Be Determined → Boost 1.63.0 |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |

For posterity, here's a reproducer:
#include<boost/optional.hpp> int main() { boost::optional<int> x; boost::optional<boost::optional<int>&> y(x); //compile error return 0; }