Convert c arrays to std::array
Needs RevisionPublic

Authored by gawin on Mon, Apr 22, 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.Mon, Apr 22, 1:55 PM
Restricted Application added a subscriber: kfm-devel. · View Herald TranscriptMon, Apr 22, 1:55 PM
gawin requested review of this revision.Mon, Apr 22, 1:55 PM
meven added a subscriber: meven.Fri, Apr 26, 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.Fri, Apr 26, 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.Sun, May 5, 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.Sun, May 5, 6:06 PM
gawin updated this revision to Diff 57616.Sun, May 5, 8:59 PM

Dived code

gawin added a comment.Sun, May 5, 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.Sun, May 12, 11:17 AM
This revision is now accepted and ready to land.Sun, May 12, 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.Sun, May 12, 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.Sun, May 12, 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.Sun, May 12, 11:41 AM