Sming icon indicating copy to clipboard operation
Sming copied to clipboard

Please add 'const' to class member functions that are not modifying the object

Open cr1st1p opened this issue 6 years ago • 3 comments

Example I bumped into, just now: DateTime::toShortDateString() Code does not change internal state of the object, so it should be declared as 'const', so that I'm allowed to use it on a 'const DateObject&'.

I think most of DateTime functions should be const.

Thank you.

cr1st1p avatar Jan 04 '18 16:01 cr1st1p

@cr1st1p Can you make a PR with the suggested changes?

slaff avatar Jan 08 '18 10:01 slaff

-Wsuggest-attribute=const might help to find any functions that are candidates.to be marked const.

frankdownunder avatar May 21 '18 10:05 frankdownunder

For the use of "const" we should make the changes across the whole Sming Framework classes and not just here and there. A "const" change should be merged with that PR #1384.

slaff avatar May 21 '18 20:05 slaff