-
Notifications
You must be signed in to change notification settings - Fork 258
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
Helper function to convert tokens to passing_styles. #198
Conversation
Also use is_literal() in an appropriate place.
@jbatez Thanks Jo, I'll look at this PR now... Re your questions: I'm currently supporting |
Also use is_literal() in an appropriate place.
As I understand it, the function parameter is initialized from the argument, which in this case would be a prvalue. Guaranteed copy elision should mean no extra copy. Clang and GCC seem to agree: https://compiler-explorer.com/z/Gr63qhY44. |
Now, |
An extra copy would happen if the cv unqualified type of the argument and of the (type referenced by the) parameter are different.
|
This issue is merged, but I don't want to lose this comment -- @JohelEGP could you please open a new issue on expanding the allowed argument qualifiers to include Thanks! |
Sure. I'll try to gather up those. |
Also use
is_literal()
in an appropriate place.I considered giving expressions starting with passing styles other than
out
,move
, orforward
explicit error messages (e.g.f(in x)
isn't allowed at this time), but a simple implementation would break expressions likei is (in(10,30))
. We could come up with some rules to detect when it looks like you're trying to actually use it as a passing style, but I wanted to ask some questions first.What are your current thoughts on explicit passing styles at call sites? Are
out
,move
, andforward
just the first you've implemented here, or were they explicitly singled out? Personally, as a user, if I know I can use some of them, I'd expect the ability to use all of them (with maybe the exception ofin
).inout
in-particular seems like important information I'd like to see at call sites. Looking at D0708, you givef2(out myb)
orf2(mutable myb)
orf2(&myb)
as options, but why notf2(inout myb)
? That seems like the most most intuitive syntax to me.copy
at call sites could be useful too. You could be saying "hey, no matter what the function signature says, take a copy of this value. I don't want you to change it and/or I don't want to accidentally change it out from under you".Also, are you thinking of them as keywords or identifiers with special meaning? If they're real keywords, detecting their misuse would be much easier.