edisionnano / QDiskInfo

QDiskInfo is a frontend for smartctl (part of the smartmontools package). It provides a user experience similar to CrystalDiskInfo. It shows the SMART (Self-Monitoring, Analysis, and Reporting Technology) data of modern hard disk drives.
GNU General Public License v3.0
102 stars 9 forks source link

Move to modern C++ auto #13

Closed riiga closed 2 months ago

riiga commented 2 months ago

This is probably a bit controversial, so feel free to reject this pull request. It's sometimes a matter of personal preference, though there are instances where it serves a purpose, like

int s = vec.size() // implicit conversion of size_type to int because the programmer assumed size was an int
auto s = vec.size() // correct type
edisionnano commented 2 months ago

What is the benefit of using the auto type? Shouldn't a mishap like the one in the example you provided be caught by -Wconversion?

riiga commented 2 months ago

It will most likely be caught by the compiler. The main benefit is that you don't have to care about the type, but there are of course various degrees to which you can use it. The main downside is you can't really tell what the type is at a glance unless you're using an IDE.

This PR is probably a bit overkill in that regard, so I'll close it. I would still recommend using auto in for loops and with iterators. Maybe I can prepare a more limited PR in the future.