[go: nahoru, domu]

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

docs: re-written no-value policies #160

Merged
merged 5 commits into from
Nov 21, 2018
Merged

docs: re-written no-value policies #160

merged 5 commits into from
Nov 21, 2018

Conversation

akrzemi1
Copy link
Collaborator

No description provided.

Copy link
Owner
@ned14 ned14 left a comment

Choose a reason for hiding this comment

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

Very different style and approach to the preceding docs. It'll be interesting to see how people react! Otherwise lots of great stuff in there, thank you.

doc/src/content/motivation/narrow_contract.md Outdated Show resolved Hide resolved
```

The compiler can see that if `pi` is null, the program would have undefined
behavior. Since undefined behavior is never the programmers intention, the compiler
Copy link
Owner

Choose a reason for hiding this comment

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

Since undefined behaviour is required by the C++ standard to be never the programmer's intention

The compiler can see that if `pi` is null, the program would have undefined
behavior. Since undefined behavior is never the programmers intention, the compiler
assumes that apparently this function is never called with `pi == nullptr`. If so,
`j` is always `0` and the code can be transformed to a faster one:
Copy link
Owner

Choose a reason for hiding this comment

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

j is always nullptr

doc/src/snippets/policies.cpp Show resolved Hide resolved
@ned14 ned14 merged commit d879be5 into ned14:develop Nov 21, 2018
ned14 added a commit that referenced this pull request Nov 21, 2018
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.

None yet

2 participants