exec::repeat_effect_until: Throwing Decay-Copy & Value Category Preservation #1723
+134
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The asynchronous loop of exec::repeat_effect_until proceeds until the child operation sends a value which converts to true. Previously this process proceeded as follows:
Unfortunately step 1 meant that the result of the child operation would be decay-copied to pass it by value. This occurred within a noexcept function and therefore if that decay-copy threw std::terminate would be called.
Moreover the previous implementation did not forward the result in step 3. This meant that if the child's result type was only rvalue convertible to bool compilation would fail.
Additionally the same pass-by-value strategy was used for errors. However when handling an error there's no need to destroy the child operation state due to the fact the operation is ending and therefore doesn't need to reconnect the child sender for the next iteration (note this logic also applies to successful completion).
Fixed all of the above by handling completion of the child operation as follows: