vsl_stream.h
Go to the documentation of this file.
1 // This is core/vsl/vsl_stream.h
2 #ifndef vsl_stream_h_
3 #define vsl_stream_h_
4 //:
5 // \file
6 // \brief Allows you to use the stream output operator instead of vsl_print_summary.
7 // \author Ian Scott
8 // So instead of
9 // \code
10 // os << "Blah: ";
11 // vsl_print_summary(os, blah);
12 // \endcode
13 // you can use
14 // \code
15 // os << "Blah: " << vsl_stream_summary(blah);
16 // \endcode
17 
18 #include <ostream>
19 #ifdef _MSC_VER
20 # include <vcl_msvc_warnings.h>
21 #endif
22 
23 
24 //: Convert a vsl_print_summary function call to a streamable object.
25 template <class T>
27 {
28  const T& x;
29  vsl_stream_summary_t(const T& xx): x(xx) {}
30 };
31 
32 template <class S>
34 {
35  return vsl_stream_summary_t<S>(xx);
36 }
37 
38 
39 //: Insert conversion object into stream
40 template <class T>
41 inline std::ostream& operator <<(std::ostream &os, const vsl_stream_summary_t<T>& sss)
42 {
43  vsl_print_summary(os, sss.x);
44  return os;
45 }
46 
47 
48 #endif // vsl_stream_h_
vsl_stream_summary_t(const T &xx)
Definition: vsl_stream.h:29
void vsl_print_summary(std::ostream &os, bool b)
Print to a stream.
vsl_stream_summary_t< S > vsl_stream_summary(const S &xx)
Definition: vsl_stream.h:33
std::ostream & operator<<(std::ostream &os, const vsl_stream_summary_t< T > &sss)
Insert conversion object into stream.
Definition: vsl_stream.h:41
Convert a vsl_print_summary function call to a streamable object.
Definition: vsl_stream.h:26