Skip to content
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

How to space ref qualifiers #5308

Closed
tkoeppe opened this issue Feb 20, 2022 · 8 comments · Fixed by #5312
Closed

How to space ref qualifiers #5308

tkoeppe opened this issue Feb 20, 2022 · 8 comments · Fixed by #5312
Assignees

Comments

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 20, 2022

Should we have a convention for how to use whitespace in ref qualifiers in the library?

void f() const &;
void f() const&;
void f() const &&;
void f() const&&;

These qualifiers are still relatively rare, so we don't really have a weight of precedence here. I'm inclined to have no space between the cv and the ref qualifier (const&). If we want to fix a style, we should record it in the wiki.

@JohelEGP
Copy link
Contributor

I'm inclined to have no space between the cv and the ref qualifier (const&).

This seems prevalent, so I've been suggesting removing spaces whenever I notice them.

@jensmaurer
Copy link
Member

I'm mildly in favor of having a space there. const& runs together too much for me. Yes, we do const T& elsewhere, but that feels somehow different.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Feb 20, 2022

Yeah, I see what you mean. I don't feel strongly either way, but do you at least think we should fix a style at all?

@jensmaurer
Copy link
Member

Yes, there should be consistent style enforced with check-source.sh (if that is technically feasible).

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 20, 2022
@tkoeppe
Copy link
Contributor Author

tkoeppe commented Feb 20, 2022

OK, great! I leave the choice to you -- I think I can see the point of cv and ref being different, separate things here, esp. since we also have a space before a & that has no const -- so it's not like T& and T const&, but more like f() & and f() const &.

@zygoloid, @opensdh: any other core perspectives here?

@opensdh
Copy link
Contributor

opensdh commented Feb 22, 2022

I generally agree: I don't tend to think of those qualifiers as actually being decl-specifiers and declarator operators, perhaps because ref-qualifiers don't influence the type of *this (even though they do affect the implicit object parameter). Moreover, in the West Const (aka Best Const) style used by the standard, one doesn't see a cv-qualifier followed immediately by a ptr-operator.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Feb 22, 2022

Jens: wants space, "too close together without space"

OpenSDH: wants space, becausethe qualifiers aren't decl-specifiers

Richard: wants space, because it's "const [T]&" where the T s omitted.

=> Let's go with the space then!

@jensmaurer
Copy link
Member

spacey!

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 22, 2022
@jensmaurer jensmaurer self-assigned this Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants