cprover
format.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_UTIL_FORMAT_H
10 #define CPROVER_UTIL_FORMAT_H
11 
12 #include <iosfwd>
13 
16 template <typename T>
18 {
19 public:
20  explicit format_containert(const T &_o) : o(_o)
21  {
22  }
23 
24  const T &o;
25 };
26 
27 template <typename T>
28 static inline std::ostream &
29 operator<<(std::ostream &os, const format_containert<T> &f)
30 {
31  return format_rec(os, f.o);
32 }
33 
34 template <typename T>
35 static inline format_containert<T> format(const T &o)
36 {
37  return format_containert<T>(o);
38 }
39 
40 #endif // CPROVER_UTIL_FORMAT_H
format
static format_containert< T > format(const T &o)
Definition: format.h:35
format_rec
static std::ostream & format_rec(std::ostream &os, const multi_ary_exprt &src)
This formats a multi-ary expression, adding parentheses where indicated by bracket_subexpression.
Definition: format_expr.cpp:101
format_containert
The below enables convenient syntax for feeding objects into streams, via stream << format(o)
Definition: format.h:18
format_containert::format_containert
format_containert(const T &_o)
Definition: format.h:20
operator<<
static std::ostream & operator<<(std::ostream &os, const format_containert< T > &f)
Definition: format.h:29
format_containert::o
const T & o
Definition: format.h:24