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

document move constructor #3918

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

WalterBright
Copy link
Member

corresponding code PR: dlang/dmd#16876

@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.

@WalterBright
Copy link
Member Author

DAutoTest doesn't like it because of the new =this syntax:

__stdin.d(3): Error: declaration expected, not `=`

$(DDSUBLINK spec/function, function-default-args, default argument),
followed by any number of parameters with default arguments.)

$(LI Its first parameter is a $(B not)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(LI Its first parameter is a $(B not)
$(LI Its first parameter is $(B not) a

A a;
a.arr = [1, 2];

A b = __rvalue(a); // move constructor gets called
Copy link
Contributor

Choose a reason for hiding this comment

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

Is __rvalue implemented by the dmd pull?

in the following situations:)

$(OL
$(LI When an rvalue is used to initialize a variable:)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about A a = A(); - the RHS is an rvalue, but presumably the move constructor is not called?

---
)

$(LI When a parameter is returned by value from a function and Named Returned Value Optimization (NRVO)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor tweak to match https://dlang.org/spec/glossary.html#nrvo.

Suggested change
$(LI When a parameter is returned by value from a function and Named Returned Value Optimization (NRVO)
$(LI When a parameter is returned by value from a function and Named Return Value Optimization (NRVO)

$(OL
$(LI When an rvalue is used to initialize a variable:)

$(SPEC_RUNNABLE_EXAMPLE_RUN
Copy link
Contributor

Choose a reason for hiding this comment

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

All the SPEC_RUNNABLE_EXAMPLE_ code needs to be COMMENT'd out to pass DAutoTest:

__stdin.d(3): Error: declaration expected, not `=`

$(H3 $(LNAME2 disable-move, Disabled Moving))

$(P Move constructor attributes work analogously to
$(LINK2 disable-copy, Disabled Copying).)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(LINK2 disable-copy, Disabled Copying).)
$(RELATIVE_LINK2 disable-copy, Disabled Copying).)

$(H3 $(LNAME2 move-constructor-attributes, Move Constructor Attributes))

$(P Move constructor attributes work analogously to
$(LINK2 copy-constructor-attributes, Copy Constructor Attributes).)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(LINK2 copy-constructor-attributes, Copy Constructor Attributes).)
$(RELATIVE_LINK2 copy-constructor-attributes, Copy Constructor Attributes).)


$(H3 $(LNAME2 disable-move, Disabled Moving))

$(P Move constructor attributes work analogously to
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(P Move constructor attributes work analogously to
$(P Disabling move construction works analogously to

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.

3 participants