Skip to content

Deprecate Unused, use C++17 [[maybe_unused]] instead#4266

Merged
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:Replace-Unused-with-maybe_unused
Nov 8, 2023
Merged

Deprecate Unused, use C++17 [[maybe_unused]] instead#4266
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
N-Dekker:Replace-Unused-with-maybe_unused

Conversation

@N-Dekker
Copy link
Contributor

Two style commits:

  • Replace Unused calls with C++17 [[maybe_unused]] attribute
  • Deprecate (ITK_FUTURE_LEGACY_REMOVE) Unused(const T &)

Removed `Unused(singletonIndex)` calls. Instead, added `[[maybe_unused]]` to
`singletonIndex` variable declarations.
@github-actions github-actions bot added the area:Core Issues affecting the Core module label Oct 23, 2023
{
// static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
// Unused(singletonIndex);
// [[maybe_unused]] static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This commented-out declaration of singletonIndex was introduced with pull request #118 commit a66337e "ENH: Synchronize factories across modules in Python", Francois Budin (@fbudin69500), February 2019:

// static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
// Unused(singletonIndex);

Maybe we might as well just remove those two commented-out lines of code. It's very hard to keep commented-out code up-to-date. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Since you already did the work, perhaps let's keep it this time. But yes, we can occasionally clean up commented-out code.

ITK itself does not call `Unused` anymore.
@N-Dekker N-Dekker force-pushed the Replace-Unused-with-maybe_unused branch from b724650 to a24573a Compare October 23, 2023 14:31
{
// static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
// Unused(singletonIndex);
// [[maybe_unused]] static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
Copy link
Member

Choose a reason for hiding this comment

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

Since you already did the work, perhaps let's keep it this time. But yes, we can occasionally clean up commented-out code.

@N-Dekker N-Dekker marked this pull request as ready for review October 24, 2023 10:30
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Nov 7, 2023

/azp run ITK.Windows

@dzenanz dzenanz merged commit 2803ebb into InsightSoftwareConsortium:master Nov 8, 2023
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants