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

Update function objects section to the new format #648

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

Conversation

Pennycook
Copy link
Contributor

Also fixes a bug in the return type of logical_and and logical_or. Closes #646.

The return types of the void specializations of maximum and minimum may require further discussion. Prior to this change, the specification didn't say exactly which operator(s) would be used to determine ordering, and so I tried to honor that in this new wording.

When we introduced the prior wording there was some discussion of trying to align with std::min and std::max (see #285 (comment)). It we want to describe the behavior in terms of equivalent statements, I think the fix is to say:

  • minimum and maximum require T to be LessThanComparable.
  • minimum returns (b < a) ? b : a.
  • maximum returns (a < b) ? b : a.

Also fixes a bug in the return type of logical_and and logical_or.
@Pennycook Pennycook added the bug Something isn't working label Oct 24, 2024
@Pennycook
Copy link
Contributor Author

Pennycook commented Oct 24, 2024

In the WG meeting today we decided that we should define the return types of the minimum and maximum operators. Because the decltype() only describes the return type of the operator, it doesn't actually constrain the implementation of the operator (i.e., it doesn't force an implementation to use a ternary). I'll make this change soon.

Note that the decltype() only describes the return type of the operator, so it
doesn't actually constrain the implementation of the operator.
- Add Precondition that T is Cpp17LessThanComparable.
- Use the same wording for the Returns paragraph.
@Pennycook
Copy link
Contributor Author

This should be read to review, now. Note that the Cpp17LessThanComparable requirement is a precondition and not a constraint. This was surprising to me, but I wanted to follow the ISO C++ definition: https://eel.is/c++draft/alg.min.max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return types of logical_and and logical_or don't match ISO C++
1 participant