Convert c arrays to std::array
Needs RevisionPublic

Authored by gawin on Apr 22 2019, 1:55 PM.

Details

Reviewers
elvisangelaccio
Group Reviewers
Dolphin
Summary

Doesn't change functionality, but allows to use range loops in different scope (than declaration), methods to check size or fill.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
gawin created this revision.Apr 22 2019, 1:55 PM
Restricted Application added a subscriber: kfm-devel. · View Herald TranscriptApr 22 2019, 1:55 PM
gawin requested review of this revision.Apr 22 2019, 1:55 PM
meven added a subscriber: meven.Apr 26 2019, 3:50 PM

For reference:
https://en.cppreference.com/w/cpp/container/array

It seems like a reasonable change to me.

src/kitemviews/kfileitemmodel.cpp
2299

Too bad we have to specify the length, it would be easy for the compiler to deduce.

gawin added a comment.Apr 26 2019, 4:01 PM

C++ 17 (only :( ) allows to change:

struct someClass{...};

std::array<someClass, 3> array{{}, {}, {}};

to :

struct someClass{...};

std::array array{someClass{}, someClass{}, someClass{}};

I think second version (without size) is harder to read. :(

elvisangelaccio requested changes to this revision.May 5 2019, 6:06 PM
elvisangelaccio added a subscriber: elvisangelaccio.
elvisangelaccio added inline comments.
src/settings/services/servicessettingspage.cpp
44 ↗(On Diff #56745)

This is an unrelated change, please use another commit for these.

This revision now requires changes to proceed.May 5 2019, 6:06 PM
gawin updated this revision to Diff 57616.May 5 2019, 8:59 PM

Dived code

gawin added a comment.May 5 2019, 9:00 PM

I'm not sure what has happened - I attached patch with 2 commits, but only one is visible.

elvisangelaccio accepted this revision.May 12 2019, 11:17 AM
This revision is now accepted and ready to land.May 12 2019, 11:17 AM

I'm not sure what has happened - I attached patch with 2 commits, but only one is visible.

Please push the commit with the std::array port, then open another revision for the other commit.

pino added a subscriber: pino.May 12 2019, 11:21 AM
pino added inline comments.
src/kitemviews/private/kbaloorolesprovider.cpp
130

won't the sizeof() here be invalid now?

elvisangelaccio requested changes to this revision.May 12 2019, 11:41 AM
elvisangelaccio added inline comments.
src/kitemviews/private/kbaloorolesprovider.cpp
130

Good catch, yes that needs to be changed

This revision now requires changes to proceed.May 12 2019, 11:41 AM