[ITK-users] itk::LightObject does not expose operator<< in .h header

Taylor Braun-Jones taylor at braun-jones.org
Fri Mar 21 14:38:56 EDT 2014


Hello Insight-users,

I'm trying to print an itk::LightObject-derived class with something like:

MyClass::Pointer fooBar = MyClass::New();
std::cout << *fooBar;


But it doesn't seem to be possible because the declaration of operator<< is
not exposed in itkLightObject.h (although one is defined in
itkLightObject.cxx). I know I can use fooBar->Print(std::cout), but this
doesn't work when I'm trying to print to a logging system that was designed
to support any object with an overloaded operator<< defined. I am able to
get things to work by defining the operator myself:

namespace std
{
ostream &
operator<<(ostream & os, const itk::LightObject & o)
{
   o.Print(os);
   return os;
}
}


But is this the intended usage?

Thanks,
Taylor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140321/c343ab8b/attachment.html>


More information about the Insight-users mailing list