Skip to content

Move, don't copy, the loaded value into the optional#348

Merged
gennaroprota merged 1 commit into
developfrom
fix/optional-move
Jul 20, 2026
Merged

Move, don't copy, the loaded value into the optional#348
gennaroprota merged 1 commit into
developfrom
fix/optional-move

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

load_impl read the value into a local and copy-assigned it to the optional. A move-only type then failed to compile: optional's perfect-forwarding assignment is removed by SFINAE when the value is not copy-assignable, leaving no viable operator=.

So, move the local into the optional instead.

The one-line fix was proposed by Venkat Murty in PR #330; this extends it with boost::move and a regression test.

`load_impl` read the value into a local and copy-assigned it to the
optional. A move-only type then failed to compile: `optional`'s
perfect-forwarding assignment is removed by SFINAE when the value is not
copy-assignable, leaving no viable `operator=`.

So, move the local into the optional instead.

The one-line fix was proposed by Venkat Murty in PR #330; this extends
it with `boost::move` and a regression test.
@gennaroprota
gennaroprota added this pull request to the merge queue Jul 20, 2026
Merged via the queue into develop with commit 64c2f11 Jul 20, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant