asioexec::completion_token: Conversion From Mutable Lvalue to Rvalue #1725
+16
−1
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.
Asio operations frequently declare completion signatures which are correct only if you ignore cv- and ref-qualification. That is to say an operation might declare void(int) as its completion signature but in actual fact complete with int& or const int& (rather than the expected int&&).
asioexec::completion_token has tried to deal with the above since it was initially added (35a3e31), however this has not been without issue (8bb5b46).
The correct way to deal with the above issue (as reified by 8bb5b46) is to use a combination of:
To determine whether values should be forwarded through to the receiver or first converted. Unfortunately compilers/standard libraries that don't feature std::reference_converts_from_temporary_v are supported hence this fallback from 8bb5b46:
Unfortunately there's a typo under the comment which reads "[r]eference type must agree except:" Both sides of the equality comparison are std:: is_lvalue_reference_v thereby rendering it tautological. This had the effect of activating the overload constrained thereby in the case where:
Leading to a compiler error of the following form:
Which is #1724 (which this commit addresses).
Added a reproducing test and fixed.