-
Notifications
You must be signed in to change notification settings - Fork 25
Add specifics to styleguide #24
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
Conversation
|
I dislike where the const keyword is put, but other than that I agree with the styleguide. const char *something;makes more intuitive sense to me. But I can get around that if everyone else agrees to have it like char const*something; |
|
I will definitely go both ways on that - the reason I originally put it after is because of the actual definition of 'const' and how it is used in other cases. const type * * const * * identifier;Which * is const? It might appear that the third * is const due to how const is first used, but it's actually the second *. If everyone prefers putting const before the type, then of course I will accept that instead. |
|
I'll have to read up on the definition of const then, because that made absolutely no sense to me, lol. |
|
http://stackoverflow.com/questions/5503352/const-before-or-const-after const int *const p; //inconsistent: sometimes left, sometimes right
int const *const p; //consistent: always leftI would also say that perhaps it shouldn't snuggle to the right to make it more clear what it is affecting. EDIT: And, of course, I somehow manage to misspell |
|
Oh I see. int const*obj; //pointer to const obj
const int *obj; //const pointer to non-const obj
---
const int obj;
int const obj; //both same thingSo then wouldn't it depend on what you're trying to do with the bit of code where you placed const? EDIT: but in the case of non-pointer objects, I have nothing against having const to the right of the type. |
Both are a non-const pointer to a const integer. const T * //non-const pointer to const T
T *const //const pointer to non-const T
T const * //non-const pointer to const TAs you can see it is inconsistent which side of the token
I assume you mean * and &, const can't snuggle next to an identifier because then it would be part of the identifier ;) |
|
Quite a lot of post editing going on, let's both take a moment to reread the whole discussion >_< |
|
You're right. That makes sense to me. And yeah that's what I meant, lol. So we're good here, now. |
Add specifics to styleguide
Make sure to view it on GitHub and not via the diff viewer to get the formatting:
https://github.com/LB--/ChessPlusPlus/tree/adjust-styleguide/src#readme
A lot more needs to be added, but I can't think of it all. Can everyone think of more ambiguous cases that need to be clarified?