Closed tcbrindle closed 8 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
2677b03
) 97.98% compared to head (e999e7c
) 97.98%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The single-pass version of
flatten_adaptor
currently does a move-assignment of an optional, which doesn't work if the inner sequence is not move-assignable -- for example if it involves a capturing lambda.This is rare, but I ran into it today doing Advent of code...
This PR fixes it in two ways. Firstly, in our
optional<T>
implementation, ifT
is copy-constructible but not copy-assignable, we destroy + construct in the assignment operator (and likewise for move). This allowsoptional<T>
to be copy/move-assignable even whenT
is not, for example if it's a capturing lambda.Secondly, we actually remove the problem by using
optional::emplace
inflatten_adaptor
, which results in fewer total operations anyway, but does require addingoptional<T&>::emplace
so things don't break.