Skip to content

Commit ee3e1f5

Browse files
committed
ENH: Use a macro to print numeric traits values of objects
Use a macro to print numeric traits values of objects. Avoids boilerplate code.
1 parent 06e75a4 commit ee3e1f5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Modules/Core/Common/include/itkMacro.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,14 @@ compilers.
12711271
ITK_MACROEND_NOOP_STATEMENT
12721272
12731273
1274+
// A useful macro in the PrintSelf method for printing member variables
1275+
// that require to be casted to the corresponding numeric value so that
1276+
// their numeric value gets printed.
1277+
#define itkPrintSelfNumericTraitsMacro(name, type) \
1278+
os << indent << #name << ": " << static_cast<typename NumericTraits<type>::PrintType>(this->m_##name) << std::endl; \
1279+
ITK_MACROEND_NOOP_STATEMENT
1280+
1281+
12741282
/** Set a decorated output. This defines the Set"name"() and a Set"name"Output() method */
12751283
#define itkSetDecoratedOutputMacro(name, type) \
12761284
virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \

0 commit comments

Comments
 (0)