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 os << "Blah: " << vsl_stream_summary(blah); \endcode 00015 #include <vcl_ostream.h> 00016 00017 00018 00019 00020 //: Convert a vsl_print_summary function call to a streamable object. 00021 template <class T> 00022 struct vsl_stream_summary_t 00023 { 00024 const T& x; 00025 vsl_stream_summary_t(const T& x): x(x) {} 00026 }; 00027 00028 template <class S> 00029 inline vsl_stream_summary_t<S> vsl_stream_summary(const S& x) 00030 { 00031 return vsl_stream_summary_t<S>(x); 00032 } 00033 00034 00035 //: Insert conversion object into stream 00036 template <class T> 00037 inline vcl_ostream& operator <<(vcl_ostream &os, const vsl_stream_summary_t<T>& sss) 00038 { 00039 vsl_print_summary(os, sss.x); 00040 return os; 00041 } 00042 00043 00044 #endif // vsl_stream_h_
1.5.1