Skip to content

[SUGGESTION] functions/lambdas in requires #434

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

Open
realgdman opened this issue May 8, 2023 · 1 comment
Open

[SUGGESTION] functions/lambdas in requires #434

realgdman opened this issue May 8, 2023 · 1 comment

Comments

@realgdman
Copy link

Not full issue, just several observations

foo: () -> bool = true;
S: <T: type> type one of requires below = { }

requires foo()
requires (foo())

  1. I haven't found way to write constexpr function in cpp2 which is needed here.
    This could be separate issue.
  2. Imagine foo is constexpr. But currently there is following cpp1 error:

error: use of undeclared identifier 'foo'
error: requires clause differs in template redeclaration

Because emitted declarations in that order:

template<typename T> requires( (foo()) ) class S //undeclared foo
auto foo() -> bool;
template<typename T> requires( (foo()) ) class S //template redeclaration
auto foo() -> bool { return true;  }

As I understand classes declared first, so we can refer them in functions, but in this case its opposite, class declaration relies on function.

  1. Immediate lambda invocation
	requires :(x)=true;(0)
	requires :(x)->_=true;(0)
	requires (:(x)->_=true;(0))

All those give cpp2 parse error

error: unexpected end of source file

Additional info, example of cpp1 requires with function and lambda
https://godbolt.org/z/a48YePnxe

@realgdman realgdman changed the title [SUGGESTION] requires and functions/lambdas [SUGGESTION] functions/lambdas in requires May 8, 2023
@JohelEGP
Copy link
Contributor

See also #323, #385.

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

No branches or pull requests

2 participants