Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add move constructor documentation #4154

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

WalterBright
Copy link
Member

As promised.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

constructors make a copy of the original, while move constructors move the contents of
the original, and the lifetime of the original ends.)

$(NOTE Do not use postblits in the same struct with move constructors.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have to have a warning like this, we should probably not support it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan on investigating if postblits should be allowed if there are move constructors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm wondering here is perhaps we have been thinking about postblit a bit wrong.

Instead of it being the third hook, make it the common denominator of both copy/move constructors. So it is always called after they are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale behind postblit was as another way to do a move constructor, not an enhancement to move constructors.

@WalterBright WalterBright force-pushed the moveConstructor branch 3 times, most recently from 4765742 to ca1fb56 Compare January 2, 2025 07:51
spec/struct.dd Show resolved Hide resolved
spec/struct.dd Show resolved Hide resolved
spec/struct.dd Outdated Show resolved Hide resolved
spec/struct.dd Outdated Show resolved Hide resolved
@WalterBright WalterBright force-pushed the moveConstructor branch 2 times, most recently from 621381d to 5ac133d Compare January 13, 2025 06:28
@WalterBright
Copy link
Member Author

ready to pull

@dkorpel dkorpel merged commit a453ed8 into dlang:master Jan 13, 2025
2 checks passed
@WalterBright WalterBright deleted the moveConstructor branch January 13, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants