15 inline ostringstream
sout() {
return ostringstream(); }
18 namespace stringstream
23 struct Indent :
Manip<Indent>
31 inline ostream&
indentInc(ostream& os) { ++priv::Indent::inst(os).level;
return os; }
34 inline ostream&
indentDec(ostream& os) { --priv::Indent::inst(os).level;
return os; }
40 inline ostream&
endl(ostream& os)
43 if (stringstream::priv::Indent::hasInst(os))
45 auto& indent = stringstream::priv::Indent::inst(os);
46 for (
int i = 0, end = indent.level * indent.size; i < end; ++i) os <<
' ';
62 inline ostream&
operator<<(ostream& os,
const exception& e) {
return os << e.what(); }
64 template<
class T1,
class T2>
65 ostream& operator<<(ostream& os, const pair<T1,T2>& p) {
return os <<
"[" << p.first <<
", " << p.second <<
"]"; }
69 template<
class Tuple,
size_t... Seq>
71 { os <<
"[";
honey::mt::exec([&]() { os << get<Seq>(forward<Tuple>(t)) << (Seq <
sizeof...(Seq)-1 ?
", " :
""); }...); os <<
"]"; }
73 void listToString(ostream& os,
const List& list) {
size_t i = 0; os <<
"[";
for (
auto& e: list) os << (i++ > 0 ?
", " :
"") << e; os <<
"]"; }
78 typename enable_if<honey::mt::isTuple<Tuple>::value, ostream&>::type
81 template<
class T,
size_t N>
82 ostream& operator<<(ostream& os, const array<T,N>& a) { priv::listToString(os, a);
return os; }
84 template<
class T,
size_t N,
typename std::enable_if<
85 !std::is_same<T,char>::value &&
86 !std::is_same<T,honey::uint8>::value &&
87 !std::is_same<T,honey::Char>::value,
int>::type=0>
88 ostream&
operator<<(ostream& os,
const T (&a)[N]) { priv::listToString(os, a);
return os; }
90 template<
class T,
class Alloc>
91 ostream& operator<<(ostream& os, const vector<T,Alloc>& vec)
92 { priv::listToString(os, vec);
return os; }
94 template<
class T,
class Compare,
class Alloc>
95 ostream& operator<<(ostream& os, const set<T,Compare,Alloc>& set)
96 { priv::listToString(os, set);
return os; }
98 template<
class T,
class Compare,
class Alloc>
99 ostream& operator<<(ostream& os, const multiset<T,Compare,Alloc>& set)
100 { priv::listToString(os, set);
return os; }
102 template<
class Key,
class Hash,
class KeyEqual,
class Alloc>
103 ostream& operator<<(ostream& os, const unordered_set<Key,Hash,KeyEqual,Alloc>& set)
104 { priv::listToString(os, set);
return os; }
106 template<
class Key,
class Hash,
class KeyEqual,
class Alloc>
107 ostream& operator<<(ostream& os, const unordered_multiset<Key,Hash,KeyEqual,Alloc>& set)
108 { priv::listToString(os, set);
return os; }
110 template<
class Key,
class T,
class Compare,
class Alloc>
111 ostream& operator<<(ostream& os, const map<Key,T,Compare,Alloc>&
map)
112 { priv::listToString(os,
map);
return os; }
114 template<
class Key,
class T,
class Compare,
class Alloc>
115 ostream& operator<<(ostream& os, const multimap<Key,T,Compare,Alloc>&
map)
116 { priv::listToString(os,
map);
return os; }
118 template<
class Key,
class T,
class Hash,
class KeyEqual,
class Alloc>
119 ostream& operator<<(ostream& os, const unordered_map<Key,T,Hash,KeyEqual,Alloc>&
map)
120 { priv::listToString(os,
map);
return os; }
122 template<
class Key,
class T,
class Hash,
class KeyEqual,
class Alloc>
123 ostream& operator<<(ostream& os, const unordered_multimap<Key,T,Hash,KeyEqual,Alloc>&
map)
124 { priv::listToString(os,
map);
return os; }
126 template<
class T,
class Fin>
127 ostream& operator<<(ostream& os, const honey::UniquePtr<T,Fin>& p)
128 {
return p ? os << *p : os <<
"nullptr"; }
131 ostream& operator<<(ostream& os, const honey::SharedPtr<T>& p)
132 {
return p ? os << *p : os <<
"nullptr"; }
auto manipFunc(Func &&f, Args &&...args)
Helper to create a manipulator that takes arguments. eg. A manip named 'foo': auto foo(int val) { ret...
Definition: StdUtil.h:243
ostream & operator<<(ostream &os, const honey::SharedPtr< T > &p)
SharedPtr to string, outputs object pointed to or 'nullptr'.
Definition: Stream.h:131
ostringstream sout()
Shorthand to create ostringstream.
Definition: Stream.h:15
ostream & indentInc(ostream &os)
Increase stream indent level by 1.
Definition: Stream.h:32
ostream & indentDec(ostream &os)
Decrease stream indent level by 1.
Definition: Stream.h:34
int size(const StdContainer &cont)
Safely get the size of a std container as a signed integer.
Definition: StdUtil.h:19
Base class to hold iostream manipulator state. Inherit from this class and call Subclass::inst(ios) t...
Definition: StdUtil.h:206
auto indentSize(int size)
Set number of spaces per indent level.
Definition: Stream.h:36
ostream & endl(ostream &os)
End line and apply any indentation to the next line.
Definition: Stream.h:40
Global Honeycomb namespace.
OutSeq && map(Range &&, Seqs &&..., OutSeq &&, Func &&)
Transform a series of sequences into an output.