Skip to content

Commit

Permalink
STYLE: Declare lambda's created for Singleton const, but non-static
Browse files Browse the repository at this point in the history
The lifetime of lambda's passed as argument to the function `Singleton<T>` does
not need to be extended beyond the function call, as these arguments directly
get converted to `std::function` objects.
  • Loading branch information
N-Dekker authored and dzenanz committed Sep 23, 2022
1 parent 48d0cb0 commit 2d19f26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkSingletonMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
{ \
if (m_##VarName == nullptr) \
{ \
static auto setLambda = [](void * a) { \
const auto setLambda = [](void * a) { \
delete m_##VarName; \
m_##VarName = static_cast<Type *>(a); \
}; \
static auto deleteLambda = []() { \
const auto deleteLambda = []() { \
delete m_##VarName; \
m_##VarName = nullptr; \
}; \
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ObjectFactoryBasePrivate : public LightObject
ObjectFactoryBasePrivate *
ObjectFactoryBase::GetPimplGlobalsPointer()
{
static auto deleteLambda = []() { m_PimplGlobals->UnRegister(); };
const auto deleteLambda = []() { m_PimplGlobals->UnRegister(); };
ObjectFactoryBasePrivate * globalInstance =
Singleton<ObjectFactoryBasePrivate>("ObjectFactoryBase", SynchronizeObjectFactoryBase, deleteLambda);
if (globalInstance != m_PimplGlobals)
Expand Down

0 comments on commit 2d19f26

Please sign in to comment.