Vcsn  2.3a
Be Rational
show.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <set>
5 #include <unordered_map>
6 #include <unordered_set>
7 #include <vector>
8 
10 #define V(S) \
11  #S ": " << S << ' '
12 
14 #define VV(S) \
15  "<" #S ":" __HERE__ << '>' << S << "</" << #S << '>'
16 
17 #define SHOW(S) std::cerr << S << std::endl
18 
19 #define SHOWV(S) SHOW(V(S))
20 
21 #define __HERE__ __FILE__ ": " << __LINE__
22 
23 #define SHOWH(S) SHOW(__HERE__ << ": " << S)
24 
25 namespace std
26 {
27  template <typename T, typename Compare, typename Alloc>
28  ostream&
29  operator<<(ostream& o, set<T, Compare, Alloc>& ts)
30  {
31  bool first = true;
32  for (const auto& t: ts)
33  {
34  if (!first)
35  o << ' ';
36  o << t;
37  first = false;
38  }
39  return o;
40  }
41 
42  template <typename Key, typename T,
43  typename Hash, typename KeyEqual, typename Alloc>
44  ostream&
45  operator<<(ostream& o, unordered_map<Key, T, Hash, KeyEqual, Alloc>& ts)
46  {
47  bool first = true;
48  for (const auto& t: ts)
49  {
50  if (!first)
51  o << ' ';
52  o << t.first << ":" << t.second;
53  first = false;
54  }
55  return o;
56  }
57 
58  template <typename Key, typename Hash, typename KeyEqual, typename Alloc>
59  ostream&
60  operator<<(ostream& o, unordered_set<Key, Hash, KeyEqual, Alloc>& ts)
61  {
62  bool first = true;
63  for (const auto& t: ts)
64  {
65  if (!first)
66  o << ' ';
67  o << t;
68  first = false;
69  }
70  return o;
71  }
72 
73  template <typename T, typename Alloc>
74  ostream&
75  operator<<(ostream& o, vector<T, Alloc>& ts)
76  {
77  bool first = true;
78  for (const auto& t: ts)
79  {
80  if (!first)
81  o << ' ';
82  o << t;
83  first = false;
84  }
85  return o;
86  }
87 }
STL namespace.