11 #include <forward_list>
18 #include <unordered_map>
19 #include <unordered_set>
24 #include "boost/container/flat_set.hpp"
25 #include "boost/container/flat_map.hpp"
30 inline std::ostream&
operator<<(std::ostream& os,
const std::forward_list<T>& l);
32 inline std::ostream&
operator<<(std::ostream& os,
const std::initializer_list<T>& l);
34 inline std::ostream&
operator<<(std::ostream& os,
const std::list<T>& l);
35 template<
typename Key,
typename Value,
typename Comparator>
36 inline std::ostream&
operator<<(std::ostream& os,
const std::map<Key, Value, Comparator>& m);
37 template<
typename Key,
typename Value,
typename Comparator>
38 inline std::ostream&
operator<<(std::ostream& os,
const std::multimap<Key, Value, Comparator>& m);
40 inline std::ostream&
operator<<(std::ostream& os,
const std::optional<T>& o);
41 template<
typename U,
typename V>
42 inline std::ostream&
operator<<(std::ostream& os,
const std::pair<U, V>& p);
43 template<
typename T,
typename C>
44 inline std::ostream&
operator<<(std::ostream& os,
const std::set<T, C>& s);
45 template<
typename... T>
46 std::ostream&
operator<<(std::ostream& os,
const std::tuple<T...>& t);
47 template<
typename Key,
typename Value,
typename H,
typename E,
typename A>
48 inline std::ostream&
operator<<(std::ostream& os,
const std::unordered_map<Key, Value, H, E, A>& m);
49 template<
typename T,
typename H,
typename K,
typename A>
50 inline std::ostream&
operator<<(std::ostream& os,
const std::unordered_set<T, H, K, A>& s);
51 template<
typename T,
typename... Tail>
52 inline std::ostream&
operator<<(std::ostream& os,
const std::variant<T, Tail...>& v);
54 inline std::ostream&
operator<<(std::ostream& os,
const std::vector<T>& v);
56 inline std::ostream&
operator<<(std::ostream& os,
const std::deque<T>& v);
66 inline auto stream_joined(
const std::string& glue,
const T& v);
77 template<
typename T,
typename F>
78 inline auto stream_joined(
const std::string& glue,
const T& v, F&& f);
89 inline std::ostream&
operator<<(std::ostream& os,
const std::forward_list<T>& l) {
101 inline std::ostream&
operator<<(std::ostream& os,
const std::initializer_list<T>& l) {
113 inline std::ostream&
operator<<(std::ostream& os,
const std::list<T>& l) {
114 return os <<
"[" << l.size() <<
": " <<
stream_joined(
", ", l) <<
"]";
124 template<
typename Key,
typename Value,
typename Comparator>
125 inline std::ostream&
operator<<(std::ostream& os,
const std::map<Key, Value, Comparator>& m) {
126 return os <<
"{" <<
stream_joined(
", ", m, [](
auto& o,
const auto& p){ o << p.first <<
" : " << p.second; }) <<
"}";
136 template<
typename Key,
typename Value,
typename Comparator>
137 inline std::ostream&
operator<<(std::ostream& os,
const std::multimap<Key, Value, Comparator>& m) {
138 return os <<
"{" <<
stream_joined(
", ", m, [](
auto& o,
const auto& p){ o << p.first <<
" : " << p.second; }) <<
"}";
149 inline std::ostream&
operator<<(std::ostream& os,
const std::optional<T>& o) {
150 if (o.has_value())
return os << *o;
151 return os <<
"empty";
161 template<
typename U,
typename V>
162 inline std::ostream&
operator<<(std::ostream& os,
const std::pair<U, V>& p) {
163 return os <<
"(" << p.first <<
", " << p.second <<
")";
173 template<
typename T,
typename C>
174 inline std::ostream&
operator<<(std::ostream& os,
const std::set<T, C>& s) {
175 return os <<
"{" << s.size() <<
": " <<
stream_joined(
", ", s) <<
"}";
185 template<
typename T,
typename C>
186 inline std::ostream&
operator<<(std::ostream& os,
const boost::container::flat_set<T, C>& s) {
187 return os <<
"{" << s.size() <<
": " <<
stream_joined(
", ", s) <<
"}";
198 template<
typename Tuple, std::size_t... I>
200 (..., (os << (I == 0 ?
"(" :
", ") << std::get<I>(t)));
212 template<
typename... T>
213 std::ostream&
operator<<(std::ostream& os,
const std::tuple<T...>& t) {
224 template<
typename Key,
typename Value,
typename H,
typename E,
typename A>
225 inline std::ostream&
operator<<(std::ostream& os,
const std::unordered_map<Key, Value, H, E, A>& m) {
226 return os <<
"{" <<
stream_joined(
", ", m, [](
auto& o,
const auto& p){ o << p.first <<
" : " << p.second; }) <<
"}";
236 template<
class Key,
class T,
class Compare,
class AllocatorOrContainer>
237 inline std::ostream&
operator<<(std::ostream& os,
const boost::container::flat_map<Key, T, Compare, AllocatorOrContainer>& m) {
238 return os <<
"{" <<
stream_joined(
", ", m, [](
auto& o,
const auto& p){ o << p.first <<
" : " << p.second; }) <<
"}";
248 template<
typename T,
typename H,
typename K,
typename A>
249 inline std::ostream&
operator<<(std::ostream& os,
const std::unordered_set<T, H, K, A>& s) {
250 return os <<
"{" << s.size() <<
": " <<
stream_joined(
", ", s) <<
"}";
260 template<
typename T,
typename... Tail>
261 inline std::ostream&
operator<<(std::ostream& os,
const std::variant<T, Tail...>& v) {
262 return std::visit([&os](
const auto& value) ->
auto& {
return os << value; }, v);
273 inline std::ostream&
operator<<(std::ostream& os,
const std::vector<T>& v) {
274 return os <<
"[" << v.size() <<
": " <<
stream_joined(
", ", v) <<
"]";
285 inline std::ostream&
operator<<(std::ostream& os,
const std::deque<T>& v) {
286 return os <<
"[" << v.size() <<
": " <<
stream_joined(
", ", v) <<
"]";
290 template<
typename T,
typename F>
296 template<
typename T,
typename F>
298 auto it = sji.
values.begin();
299 if (it == sji.
values.end()) {
303 for (++it; it != sji.
values.end(); ++it) {
312 auto f = [](
auto& os,
const auto& t){ os << t; };
316 template<
typename T,
typename F>
carl is the main namespace for the library.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
void visit(const Formula< Pol > &formula, Visitor func)
Recursively calls func on every subformula.
auto stream_joined(const std::string &glue, const T &v)
Allows to easily output some container with all elements separated by some string.
std::ostream & stream_tuple_impl(std::ostream &os, const Tuple &t, std::index_sequence< I... >)
Helper function that actually outputs a std::tuple.
std::ostream & operator<<(std::ostream &os, const stream_joined_impl< T, F > &sji)