-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
QEP 314: Relax prohibition against "auto" #319
Conversation
Allow use of "auto" for variable types when the variable type is explicitly stated during its initialization
FYI @rouault |
What is the motivation for this? |
It's to make super verbose lines like these less painful to write:
in this case it's still immediately clear to reviewers/readers if it's written like:
|
Being allergic to auto, +1 to restricting this relaxation to only std::unique_ptr / std::shared_ptr as suggested above. |
Being an auto worshiper, +1 to relaxing. |
@elpaso , heh, that had my laugh out loud :) |
not a great fan of auto so +1 to restricting to only std::unique_ptr / std::shared_ptr. |
Now I feel like I have to voice my opinion too :) I like By the way, thanks @nyalldawson for these coding style QEPs. A comprehensive coding standard was something I sorely missed when starting with QGIS development. |
My issue with that is that it requires an IDE to actually determine the object type. Eg in this case "index()" could quite validly return a QgsSpatialIndex, a QgsKdBushSpatialIndex, or something else entirely (a QHash? A QMap?). In short, it makes pull request reviews orders of magnitude more difficult. |
+1 for non trivial sounds good. Are iterators listed as acceptable somewhere already? |
Small note: If |
I think this is worth discussing in a different proposal (to keep this one focussed), there are a few considerations to be made but in general it's a desirable direction IMHO. |
generally speaking, we should avoid using new as much as possible and favor smart pointers (std::make_unique, etc) where possible |
I definitely agree, but it's used in the codebase today and it's not always possible to sanely replace it with a smart pointer. In the future, I'd love to see some discussion on how we can further move away from raw pointers (the main blockers right now are Qt and SIP AFAIK), but for now I just don't want to have to keep writing |
+1. @dvdkon would you like to create that QEP? |
Ok, based on feedback this is now restricted to |
Co-authored-by: Matthias Kuhn <[email protected]>
This is ready for voting now |
+1 Even |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Allow use of
auto
for variable types when the variable type is explicitly stated during its initialization.Specifically:
auto
may be used for variable types if the type is explicit during variable initialization. Eg