core/vsl/vsl_stream.h
Go to the documentation of this file.
00001 // This is core/vsl/vsl_stream.h
00002 #ifndef vsl_stream_h_
00003 #define vsl_stream_h_
00004 //:
00005 // \file
00006 // \brief Allows you to use the stream output operator instead of vsl_print_summary.
00007 // \author Ian Scott
00008 // So instead of
00009 // \code
00010 //   os << "Blah: ";
00011 //   vsl_print_summary(os, blah);
00012 // \endcode
00013 // you can use
00014 // \code
00015 //   os << "Blah: " << vsl_stream_summary(blah);
00016 // \endcode
00017 
00018 #include <vcl_ostream.h>
00019 
00020 
00021 //: Convert a vsl_print_summary function call to a streamable object.
00022 template <class T>
00023 struct vsl_stream_summary_t
00024 {
00025   const T& x;
00026   vsl_stream_summary_t(const T& xx): x(xx) {}
00027 };
00028 
00029 template <class S>
00030 inline vsl_stream_summary_t<S> vsl_stream_summary(const S& xx)
00031 {
00032   return vsl_stream_summary_t<S>(xx);
00033 }
00034 
00035 
00036 //: Insert conversion object into stream
00037 template <class T>
00038 inline vcl_ostream& operator <<(vcl_ostream &os, const vsl_stream_summary_t<T>& sss)
00039 {
00040   vsl_print_summary(os, sss.x);
00041   return os;
00042 }
00043 
00044 
00045 #endif // vsl_stream_h_