[ITK] [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://public.kitware.com/pipermail/community/attachments/20140321/c343ab8b/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list