ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itk::print_helper Namespace Reference

Functions

template<typename T, vcl_size_t VLength>
std::ostream & operator<< (std::ostream &os, const std::array< T, VLength > &container)
 
template<typename T>
std::ostream & operator<< (std::ostream &os, const std::list< T > &l)
 
template<typename T>
std::ostream & operator<< (std::ostream &os, const std::vector< T > &v)
 
template<typename T, vcl_size_t VLength, typename = std::enable_if_t<!std::is_same_v<T, char>>>
std::ostream & operator<< (std::ostream &os, const T(&arr)[VLength])
 
template<typename T>
void PrintNumericTrait (std::ostream &os, const Indent &indent, const char *name, const T &value)
 

Function Documentation

◆ operator<<() [1/4]

template<typename T, vcl_size_t VLength>
std::ostream & itk::print_helper::operator<< ( std::ostream & os,
const std::array< T, VLength > & container )

Definition at line 150 of file itkPrintHelper.h.

◆ operator<<() [2/4]

template<typename T>
std::ostream & itk::print_helper::operator<< ( std::ostream & os,
const std::list< T > & l )

Definition at line 133 of file itkPrintHelper.h.

◆ operator<<() [3/4]

template<typename T>
std::ostream & itk::print_helper::operator<< ( std::ostream & os,
const std::vector< T > & v )

Definition at line 113 of file itkPrintHelper.h.

◆ operator<<() [4/4]

template<typename T, vcl_size_t VLength, typename = std::enable_if_t<!std::is_same_v<T, char>>>
std::ostream & itk::print_helper::operator<< ( std::ostream & os,
const T(&) arr[VLength] )

Definition at line 170 of file itkPrintHelper.h.

◆ PrintNumericTrait()

template<typename T>
void itk::print_helper::PrintNumericTrait ( std::ostream & os,
const Indent & indent,
const char * name,
const T & value )
inline

Print "<name>: <value>\n" indented, matching ITK's PrintSelf style.

Formats and writes a single named member to os preceded by indent, followed by a newline. When NumericTraits<T>::PrintType differs from T (the relevant case being the char family, whose PrintType is int, so values render numerically rather than as ASCII characters) the value is forwarded through a static_cast. When the two types coincide (the common case, including all built-in scalars wider than char and std::complex specialisations whose PrintType is Self) the cast step is skipped entirely so the value's own stream insertion overload is selected directly.

Equivalent to the boilerplate

os << indent << "Name: "
<< static_cast<typename NumericTraits<T>::PrintType>(m_Name)
<< std::endl;

but with explicit os and indent parameters and no preprocessor macro expansion.

Typical use inside a PrintSelf override:

print_helper::PrintNumericTrait(os, indent, "Threshold", m_Threshold);
void PrintNumericTrait(std::ostream &os, const Indent &indent, const char *name, const T &value)
Print "<name>: <value>\n" indented, matching ITK's PrintSelf style.

Definition at line 98 of file itkPrintHelper.h.

Referenced by itk::AnnulusOperator< TPixel, TDimension, TAllocator >::PrintSelf(), itk::Function::ColormapFunction< InputImagePixelType, OutputImagePixelType >::PrintSelf(), and itk::ShapeLabelObject< LabelType, Self::ImageDimension >::PrintSelf().