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

LWG Poll 5: P1460R1 Mandating the Standard Library: Clause 20 - Utilities library #3788

Merged
merged 1 commit into from Feb 28, 2020

Conversation

zygoloid
Copy link
Member

Fixes #3707.

Also fixes cplusplus/papers#726.

source/utilities.tex Show resolved Hide resolved

\pnum
\constraints
\tcode{is_constructible_v<$\tcode{T}_I$, Args...>} is \tcode{true}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Constraints: come before Mandates:.

Copy link
Member Author

Choose a reason for hiding this comment

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

As above, this is as requested by the wording paper.

Copy link
Member Author

@zygoloid zygoloid Feb 25, 2020

Choose a reason for hiding this comment

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

... but this wording is meaningless. We can't have a Mandates: on a property of T_I if we only have a Constraints: that I is in-bounds. That doesn't make any sense.

I've mailed LWG to ask what they want here. I propose we leave the wording alone (and don't reorder these elements) for now -- reordering these elements obscures the likely intent (for the Mandates: to apply before overload resolution).


\pnum
\constraints
\tcode{is_constructible_v<$\tcode{T}_I$, initializer_list<U>\&, Args...>} is \tcode{true}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Constraints: come before Mandates:.

Copy link
Member Author

Choose a reason for hiding this comment

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

As above, this is as requested by the wording paper.

source/utilities.tex Outdated Show resolved Hide resolved
source/utilities.tex Outdated Show resolved Hide resolved
source/utilities.tex Show resolved Hide resolved
source/utilities.tex Show resolved Hide resolved
\tcode{T} is \tcode{U[]} and \tcode{Y(*)[]} is convertible to \tcode{T*}.
When \tcode{T} is not an array type,
the expression \tcode{delete p} is well-formed and
\tcode{Y*} is convertible to \tcode{T*}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Constraints: come before Mandates:.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm concerned this will change the presumptive intent. Consider:

#include <memory>
struct Base; struct Derived;
bool k = requires (Derived *p) { std::shared_ptr<Base*>(p); };

Does this violate a Mandates or a Constraints? (Put another way: is the above program guaranteed to be well-formed, or could it result in a non-immediate-context error?)

With the current order of elements, the suggestion (albeit a flawed one) is that the program can be rejected. Reversing the order of elements removes the suggestion that the Mandates: could somehow mysteriously apply prior to overload resolution, requiring that example to be accepted.

\requires
\tcode{alignment} shall be a power of two.
\expects
\tcode{alignment} is a power of two.
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
\tcode{alignment} is a power of two.
\tcode{has_single_bit(alignment)} is \tcode{true}.

Copy link
Member Author

Choose a reason for hiding this comment

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

We're trying to express the requirement that the alignment be a power of 2. We get no benefit from circumlocution via a (now-terribly-named) library function.

We should generally prefer plain simple descriptions, not description-by-mechanism, where possible (for example, requirements like "is_same_v<T, U> is false" are uniformly awful, and requiring "T is not the same type as U" would be much clearer and simpler).

source/utilities.tex Show resolved Hide resolved
@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Feb 23, 2020
@zygoloid zygoloid removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Feb 25, 2020
@zygoloid
Copy link
Member Author

Other than the problematic cases (where reordering the elements could change the meaning), the remaining comments from @JohelEGP should be addressed by #3795.

Ignored requested change from "Requires:" to "Mandates:" for
tuple(tuple&&) constructor. This has already been replaced with
"Constraints:" by LWG 2899.
@zygoloid zygoloid merged commit 6b63d93 into master Feb 28, 2020
@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 29, 2020

And if it weren't for Annex D, we could even get rid of the Requires element from the library specification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants