Skip to content

Commit 2d19f26

Browse files
N-Dekkerdzenanz
authored andcommitted
STYLE: Declare lambda's created for Singleton const, but non-static
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.
1 parent 48d0cb0 commit 2d19f26

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Modules/Core/Common/include/itkSingletonMacro.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
{ \
4545
if (m_##VarName == nullptr) \
4646
{ \
47-
static auto setLambda = [](void * a) { \
47+
const auto setLambda = [](void * a) { \
4848
delete m_##VarName; \
4949
m_##VarName = static_cast<Type *>(a); \
5050
}; \
51-
static auto deleteLambda = []() { \
51+
const auto deleteLambda = []() { \
5252
delete m_##VarName; \
5353
m_##VarName = nullptr; \
5454
}; \

Modules/Core/Common/src/itkObjectFactoryBase.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ObjectFactoryBasePrivate : public LightObject
117117
ObjectFactoryBasePrivate *
118118
ObjectFactoryBase::GetPimplGlobalsPointer()
119119
{
120-
static auto deleteLambda = []() { m_PimplGlobals->UnRegister(); };
120+
const auto deleteLambda = []() { m_PimplGlobals->UnRegister(); };
121121
ObjectFactoryBasePrivate * globalInstance =
122122
Singleton<ObjectFactoryBasePrivate>("ObjectFactoryBase", SynchronizeObjectFactoryBase, deleteLambda);
123123
if (globalInstance != m_PimplGlobals)

0 commit comments

Comments
 (0)