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

(primary-expression && ...) in a requires-clause #6051

Closed
notbob-at-tessellation-com opened this issue Jan 18, 2023 · 6 comments
Closed

(primary-expression && ...) in a requires-clause #6051

notbob-at-tessellation-com opened this issue Jan 18, 2023 · 6 comments

Comments

@notbob-at-tessellation-com
Copy link

notbob-at-tessellation-com commented Jan 18, 2023

Hello,

Today I am making my first posts to this group. Please forgive me if I make mistakes. Thank you.

Here is the context:

Header <iterator>:

template<class F, class... Is>
requires (indirectly_readable<Is> && ...) && invocable<F, iter_reference_t<Is>...>
using indirect_result_t = invoke_result_t<F, iter_reference_t<Is>...>;

Header <variant>:

template<class... Types> requires (three_way_comparable<Types> && ...)
constexpr common_comparison_category_t<compare_three_way_result_t<Types>...>
operator<=>(const variant<Types...>&, const variant<Types...>&);

A requires-clause has the following grammar:

requires-clause:
requires constraint-logical-or-expression
constraint-logical-or-expression:
constraint-logical-and-expression
constraint-logical-or-expression || constraint-logical-and-expression
constraint-logical-and-expression:
primary-expression
constraint-logical-and-expression && primary-expression

In <iterator>, "(indirectly_readable<Is> && ...)", I understand "indirectly_readable<Is>" is a primary-expression, but "..." is not.
In <variant>, "(three_way_comparable<Types> && ...)", I understand "three_way_comparable<Types>" is a primary-expression, but "..." is not.

Am I misunderstanding something, or is this an error?

Thank you,

Robert Schwartz

@jwakely
Copy link
Member

jwakely commented Jan 18, 2023

This is not an editorial question, please use the std-discussion forum instead:
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

@jwakely
Copy link
Member

jwakely commented Jan 18, 2023

N.B. I've edited your original post to add markdown formatting, so it's rendered correctly, without <iterator> being treated as HTML markup.

@notbob-at-tessellation-com
Copy link
Author

@jwakely
Copy link
Member

jwakely commented Jan 18, 2023

Am I misunderstanding something, or is this an error?

To save you the time of going to std-discussion, you're misunderstanding. Those are both a fold-expression in the grammar, see [expr.prim.fold]. You need to consider the whole expression, it's not ( primary-expression && ... ) it's all just a fold-expression.

@notbob-at-tessellation-com
Copy link
Author

@notbob-at-tessellation-com
Copy link
Author

@jensmaurer jensmaurer closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
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

No branches or pull requests

3 participants