-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: accept function type argument #923
base: main
Are you sure you want to change the base?
Conversation
From #628:
Can you elaborate with examples where this is used? I'm not seeing the use cases in the PR code shown so far, unless the answer to my first question about |
_ = typeid(int); | ||
_ = offsetof(t, a); | ||
_ = :<T> (_: T) _ = sizeof(T::value);(std::true_type()); | ||
_ = :<T> (_: T) _ = sizeof(type T::value_type);(std::true_type()); |
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.
Is there intended to be a difference between lines 7 and 8? Or is the type
intended to be optional?
If there's no difference, can you show a case where it's required?
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.
The second one needs the disambiguating type
.
See https://cpp1.godbolt.org/z/PY53n6Kvf (generated from https://cpp2.godbolt.org/z/KK15vf6Y5):
- Clang:
error: dependent-name 'T::value_type' is parsed as a non-type, but instantiation yields a type
. - GCC:
error: missing 'typename' prior to dependent type name 'integral_constant<bool, true>::value_type'
. - MSVC accepts.
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.
D'oh, now I see it. I missed the _type
suffix that changed the meaning, sorry.
@@ -5,7 +5,7 @@ testing_enabled: bool = false; | |||
|
|||
outer: @print type = { | |||
|
|||
object_alias: <T> T requires true == 42; | |||
object_alias: <T> T requires true == sizeof(type T::value_type); |
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.
Is this just to exercise type
for this pretty-print self-test, or is type
now intended to be required here?
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.
The former.
This change is intended to exercise the type
keyword in the pretty-print.
@@ -5800,9 +5845,6 @@ class parser | |||
//G postfix-expression | |||
//G prefix-operator prefix-expression | |||
//GTODO await-expression | |||
//GTODO 'sizeof' '(' type-id ')' | |||
//GTODO 'sizeof' '...' ( identifier ')' | |||
//GTODO 'alignof' '(' type-id ')' |
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.
Right, these should go anyway as they already work without a special grammar. And throws-expression too, since throw(...)
works (and I'm using that in reflect.h2
's report_violation
function).
Resolves #628 (comment).
Testing summary:
Acknowledgements: