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
[string.cons] Replace postcondition tables by ordinary Postcondition elements #1876
Conversation
I think you lost the former table 61. Shouldn't there be a "Postcondition:" after (what is now) 24.3.2.2/25? |
On the other hand, maybe table 61 was just in the wrong place before (in N4713). |
@mclow: The old Table 61 is now paragraph 23. |
source/strings.tex
Outdated
\tcode{data()} points at the first element of an allocated copy | ||
of the array whose first element is pointed at by \tcode{s}, | ||
\tcode{size()} is equal to \tcode{traits::length(s)}, and | ||
\tcode{capacity()} is a value at least as large as \tcode{size()}. | ||
\end{itemdescr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate space after capacity()? (Not that it matters.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will fix.
Looks good to me. |
source/strings.tex
Outdated
\postconditions | ||
\tcode{data()} points at the first element of an allocated copy of the | ||
array whose first element is pointed at by \tcode{str.data()}, | ||
\tcode{size()} is equal to \tcode{str.size()}, and \tcode{capacity()} is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right. size()
is equal to the value that str.size()
had prior to the call, right? str.size()
is unspecified for the second overload. (Likewise for data()
.) I think we're usually more explicit about whether we're talking about the before / after value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it help if I added "the original value of" in a few places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zygoloid: "original value" is what the allocator versions already use. In fact, my attempt to add "original value" to the description here led me to independently invent identical wording!
source/strings.tex
Outdated
\tcode{*this} | ||
and \tcode{str} are the same object, | ||
the member has no effect. | ||
If \tcode{*this} and \tcode{str} are not the same object, modifies \tcode{*this}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need to say "as described below" or something here. Otherwise, a reader is left thinking "ok, but how?" Maybe this should be merged into the postconditions instead, though, since the "points at [...] an allocated copy" postcondition is not correct in the this == &str
case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I turned the two conditions around and made the second one say "see below".
source/strings.tex
Outdated
\tcode{alloc}. In the second form, \tcode{str} is left in a valid state with an | ||
\effects Constructs an object of class \tcode{basic_string}. | ||
The stored allocator is constructed from \tcode{alloc}. | ||
In the second form, \tcode{str} is left in a valid state with an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the corresponding constructors without an allocator parameter, this sentence is a postcondition rather than an effect. We should be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
source/strings.tex
Outdated
\tcode{data()} points at the first element of an allocated copy | ||
of the array whose first element is pointed at by \tcode{str.data()}, | ||
\tcode{size()} is equal to \tcode{str.size()}, and | ||
\tcode{capacity()} is a value at least as large as \tcode{size()}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "If *this
and str
are the same object" condition should be moved down here -- the postcondition should ideally be written such that it applies for all (valid) calls to the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved or copied? Do you want to delete the Effects clause?
source/strings.tex
Outdated
\end{libefftabvalue} | ||
\pnum | ||
\postconditions | ||
\effects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray \effects
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes, also stray pnum
above. (Which prints very strangely.) Fixed.
Fixes #1875.