-
Notifications
You must be signed in to change notification settings - Fork 168
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
Basic support for C++20 concepts #132
Comments
The particular error is caused by the skip here: https://github.com/foonathan/cppast/blob/e558e2d58f519e3a83af770d460672b1d4ba2886/src/libclang/template_parser.cpp#L137. It needs to account for the presence of a concept name as well, with a potential update to The following should work:
If you do a PR, it'll be fixed more quickly. ;) In the long-term, I plan on moving away from libclang to clang JSON, see #120. If I find the time, I might add proper concept support. |
I implemented the proposed changes which fixes the issue described above here. But it will only work in this simple case. I wrote some additional tests for abbreviated function templates and requires clauses/constraints. These constraint tests are not exhaustive and do not cover conjunctions, disjunctions, atomic constraints and requires expressions. I feel like this is not enough to warrant a PR yet. At the very least there should be some logic to ignore the different types of constraints. |
Thanks for looking into it in more detail.
Yes, that requires support for libclang as well. I don't know the C++20 support in libclang, but it's probably bad.
Can you post the error messages you're getting with those examples? |
Of course, here is the output when running cppast_test with the added tests:
|
Hm, that's odd. The assertion is generated here, but I can't see why it would generate - you haven't touched the function prefix at all: https://github.com/foonathan/cppast/blob/main/src/libclang/function_parser.cpp#L301 Maybe the computed name or associated tokens are weird? |
Fixed by #144 :) |
Would it be possible to add basic support for C++20 concepts? For my use case I wouldn't need any advanced details about them and it would be sufficient if the parser could detect and ignore them without generting warnings/errors.
Declaring a concept generates a warning but the parser skips over it:
Input flags: -v --std c++20
Output:
Using it for a templated type generates an error:
Input flags: -v --std c++20
Output:
The text was updated successfully, but these errors were encountered: