Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Modules/Core/Common/include/itkSingleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@
#include <map>
#include <functional>

#ifndef ITK_FUTURE_LEGACY_REMOVE
/** \brief A function which does nothing
* \deprecated Preferably use the C++ `[[maybe_unused]]` attribute instead!
*
* This function is to be used to mark parameters as unused to suppress
* compiler warning. It can be used when the parameter needs to be named
* (i.e. itkNotUsed cannot be used) but is not always used.
*/
template <typename T>
inline void
[[deprecated("Preferably use the C++ `[[maybe_unused]]` attribute instead!")]] inline void
Unused(const T &){};
#endif

namespace itk
{
Expand Down Expand Up @@ -124,9 +127,8 @@ template <typename T>
T *
Singleton(const char * globalName, std::function<void()> deleteFunc)
{
static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
Unused(singletonIndex);
T * instance = SingletonIndex::GetInstance()->GetGlobalInstance<T>(globalName);
[[maybe_unused]] static SingletonIndex * singletonIndex = SingletonIndex::GetInstance();
T * instance = SingletonIndex::GetInstance()->GetGlobalInstance<T>(globalName);
if (instance == nullptr)
{
instance = new T;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,7 @@ ObjectFactoryBase::SynchronizeObjectFactoryBase(void * objectFactoryBasePrivate)
std::list<ObjectFactoryBase *>
ObjectFactoryBase::GetRegisteredFactories()
{
// 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.

ObjectFactoryBase::Initialize();
return m_PimplGlobals->m_RegisteredFactories;
}
Expand Down