-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix 12372: C++20: syntaxError with implicit operator and requires clause #6397
Fix 12372: C++20: syntaxError with implicit operator and requires clause #6397
Conversation
for (tok = tok->next(); tok && !Token::Match(tok, ";|{"); tok = tok->next()) { | ||
if (tok->link() && Token::Match(tok, "<|[|(")) | ||
tok = tok->link(); | ||
if (Token::simpleMatch(tok, "bool {")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be "%bool% {"
? But apparently it's not needed at all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is for checking when doing explicit conversion to bool as the requires clause doesnt allow implicit conversion to bool so then the user will need to explicitly convert with either static_cast<bool>(...)
, (bool) ...
, bool(...)
or bool{...}
. However, the latter(ie bool{}
) will exit the loop on {
so this extra check is there to continue with the explicit conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is needed for something, we should have a test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test.
@chrchr-github @danmar Any more feedback? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No description provided.