Skip to content

[unique.ptr.single] Align preconditions and postconditions with the guidelines #7982

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MikailBag
Copy link

According to https://github.com/cplusplus/draft/wiki/Specification-Style-Guidelines#formatting-declarations-and-definitions, conditions should be expressed as <expr> is true instead of simply <expr>. It seems that std::unique_ptr specification does not comply with that.

This PR updates all such places that I have spotted.

…uidelines

According to https://github.com/cplusplus/draft/wiki/Specification-Style-Guidelines#formatting-declarations-and-definitions, conditions should be expressed as `<expr> is true` instead of simply `<expr>`. It seems that `std::unique_ptr` specification does not comply with that.

This PR updates all such places that I have spotted.
@MikailBag MikailBag marked this pull request as ready for review June 22, 2025 19:06
@@ -2549,8 +2549,8 @@

\pnum
\ensures
If \tcode{this != addressof(u)},
\tcode{u.get() == nullptr},
If \tcode{this != addressof(u)} is \tcode{true},
Copy link
Author

@MikailBag MikailBag Jun 22, 2025

Choose a reason for hiding this comment

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

Perhaps this (and similar condition below) should be inverted to \tcode{this == addressof(u)} is \tcode{false}.
I'm not sure which way is more readable

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we can simply say "this == addressof(u) || u.get() == nullptr is true".

Copy link
Author

Choose a reason for hiding this comment

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

But there is also an else branch, so it will look like this:

* `this == addressof(u) || u.get() == nullptr` is `true`
* `this != addressof(u)` is `true` or `u.get()` is unchanged

Looks a bit too complex to me.

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.

2 participants