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

[string.cons] Replace postcondition tables by ordinary Postcondition elements #1876

Merged
merged 1 commit into from Dec 5, 2017

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Dec 3, 2017

Fixes #1875.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Dec 3, 2017

@mclow, @zygoloid, could you please take a look?

@mclow
Copy link
Contributor

mclow commented Dec 3, 2017

I think you lost the former table 61. Shouldn't there be a "Postcondition:" after (what is now) 24.3.2.2/25?

@mclow
Copy link
Contributor

mclow commented Dec 3, 2017

On the other hand, maybe table 61 was just in the wrong place before (in N4713).

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Dec 3, 2017

@mclow: The old Table 61 is now paragraph 23.

\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}
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will fix.

@jensmaurer
Copy link
Member

Looks good to me.

\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
Copy link
Member

@zygoloid zygoloid Dec 4, 2017

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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!

\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}.
Copy link
Member

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.

Copy link
Contributor Author

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

\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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

\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()}.
Copy link
Member

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.

Copy link
Contributor Author

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?

\end{libefftabvalue}
\pnum
\postconditions
\effects
Copy link
Member

Choose a reason for hiding this comment

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

Stray \effects?

Copy link
Contributor Author

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.

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

4 participants