-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only convert
type_of
to the Cpp2 macro if unqualified
- Loading branch information
Showing
3 changed files
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"9A09:1351" | ||
"9A10:0946" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0853341
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.
I'm reading https://isocpp.org/files/papers/D2996R7.html.
It seems there's a
type_of
we can use UFCS on.However,
0.type_of()
currently lowers toCPP2_UFCS(CPP2_TYPEOF)(0)
(https://cpp2.godbolt.org/z/jbjWjr8q6).We should review these Cpp2 keywords and ensure their unqualified use in UFCS doesn't treat them specially.
0853341
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.
But what about types, like
u32
?arg.Type()
is something we sold for UFCS.I think
0.u32()
should continue to have the same effects as its current lowering toCPP2_UFCS(cpp2::u32)(0)
(https://cpp2.godbolt.org/z/YMx3G1133).But what if the argument isn't
0
,but of a type with a
u32
member,or there's a
u32
function object in scope,or anything else that makes
x..u32()
oru32(x)
valid?It seems like we would need to enhance the UFCS macro
to conditionally try the
cpp2::
-qualified name as a last resort.0853341
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.
Interestingly, I tried writing a type with a
u32
member (https://cpp2.godbolt.org/z/d6cbjxhxz):But it's declared as
Is this intended?
Right now, the hypothetical
x.u32()
above does work asx.__identifier__u32()
.So does declaring the member like that (https://cpp2.godbolt.org/z/3sWrazTvn):
So, maybe there's nothing to do?
Except diagnosing the use of those Cpp2 type keywords outside expressions and type-only contexts.
And maybe still enhancing the UFCS macro to add a
static_assert
suggesting the use of__identifier__
.0853341
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.
There's an easier solution.
For
x.u32()
, we could allow that to call au32
member, or always treat that ascpp2::u32
.In the former case, we need to enhance the UFCS macro.
The latter case has the easier solution.
That is a separate UFCS macro, since we know we're dealing with a Cpp2 type keyword,
that just checks for validity and otherwise suggests the use of
__identifier__
.