Skip to content

STYLE: Remove this-> on access to private data ResourceProbe#5316

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ResourceProbe-remove-this-access
Apr 22, 2025
Merged

STYLE: Remove this-> on access to private data ResourceProbe#5316
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ResourceProbe-remove-this-access

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

Replaced this->m_ with m_ in "itkResourceProbe.hxx". Removed parentheses
from ++(m_NumberOfStarts) and ++(m_NumberOfStops).

Following section "Accessing Members" of ITK's Coding Style Guide

Replaced `this->m_` with `m_` in "itkResourceProbe.hxx". Removed parentheses
from `++(m_NumberOfStarts)` and `++(m_NumberOfStops)`.

Following section "Accessing Members" of ITK's Coding Style Guide,
https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/blob/v5.4.3/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex#L1708
@github-actions github-actions bot added area:Core Issues affecting the Core module type:Style Style changes: no logic impact (indentation, comments, naming) labels Apr 18, 2025
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I sometimes had to add this-> was that GCC threw compile errors without it. Hopefully this PR doesn't run into that issue.

@N-Dekker
Copy link
Copy Markdown
Contributor Author

The reason I sometimes had to add this-> was that GCC threw compile errors without it.

@dzenanz Do you remember in what kind of scenario those GCC compile errors appeared? I think it should be OK to just remove the this-> from access to data members, unless it's inside a template class, accessing the non-private data of its base class. In this case (this PR), it's just access to its own private data, so that should be just fine.

By the way, if it would be access to the non-private data of its base class, I think it would be clearer to do it by Superclass::m_Data (instead of this->m_Data). Right?

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Apr 18, 2025

Yes, this issue arises in templated classes (sometimes). You might be completely right.

@N-Dekker N-Dekker marked this pull request as ready for review April 18, 2025 16:04
@N-Dekker
Copy link
Copy Markdown
Contributor Author

Yes, this issue arises in templated classes (sometimes). You might be completely right.

Thanks @dzenanz For the sake of completeness, it appears that those GCC compile errors only appear when both the derived and the base class is templated. And the derived tried to access a non-private data member from its base.

@dzenanz dzenanz merged commit de0106a into InsightSoftwareConsortium:master Apr 22, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Style Style changes: no logic impact (indentation, comments, naming)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants