}
}
+std::ostream& operator<<(std::ostream& out, const std::vector<Expr>& container)
+{
+ container_to_stream(out, container);
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, const std::set<Expr>& container)
+{
+ container_to_stream(out, container);
+ return out;
+}
+
+std::ostream& operator<<(
+ std::ostream& out,
+ const std::unordered_set<Expr, ExprHashFunction>& container)
+{
+ container_to_stream(out, container);
+ return out;
+}
+
+template <typename V>
+std::ostream& operator<<(std::ostream& out, const std::map<Expr, V>& container)
+{
+ container_to_stream(out, container);
+ return out;
+}
+
+template <typename V>
+std::ostream& operator<<(
+ std::ostream& out,
+ const std::unordered_map<Expr, V, ExprHashFunction>& container)
+{
+ container_to_stream(out, container);
+ return out;
+}
+
TypeCheckingException::TypeCheckingException(const TypeCheckingException& t)
: Exception(t.d_msg), d_expr(new Expr(t.getExpression()))
{
#include <iosfwd>
#include <iterator>
#include <string>
+#include <map>
+#include <set>
#include <unordered_map>
+#include <unordered_set>
#include "base/exception.h"
#include "options/language.h"
*/
std::ostream& operator<<(std::ostream& out, const Expr& e) CVC4_PUBLIC;
+/**
+ * Serialize a vector of expressions to given stream.
+ *
+ * @param out the output stream to use
+ * @param container the vector of expressions to output to the stream
+ * @return the stream
+ */
+std::ostream& operator<<(std::ostream& out, const std::vector<Expr>& container);
+
+/**
+ * Serialize a set of expressions to the given stream.
+ *
+ * @param out the output stream to use
+ * @param container the set of expressions to output to the stream
+ * @return the stream
+ */
+std::ostream& operator<<(std::ostream& out, const std::set<Expr>& container);
+
+/**
+ * Serialize an unordered_set of expressions to the given stream.
+ *
+ * @param out the output stream to use
+ * @param container the unordered_set of expressions to output to the stream
+ * @return the stream
+ */
+std::ostream& operator<<(
+ std::ostream& out,
+ const std::unordered_set<Expr, ExprHashFunction>& container);
+
+/**
+ * Serialize a map of expressions to the given stream.
+ *
+ * @param out the output stream to use
+ * @param container the map of expressions to output to the stream
+ * @return the stream
+ */
+template <typename V>
+std::ostream& operator<<(std::ostream& out, const std::map<Expr, V>& container);
+
+/**
+ * Serialize an unordered_map of expressions to the given stream.
+ *
+ * @param out the output stream to use
+ * @param container the unordered_map of expressions to output to the stream
+ * @return the stream
+ */
+template <typename V>
+std::ostream& operator<<(
+ std::ostream& out,
+ const std::unordered_map<Expr, V, ExprHashFunction>& container);
+
// for hash_maps, hash_sets..
struct ExprHashFunction {
size_t operator()(CVC4::Expr e) const;
return out;
}
-namespace {
-
-template <typename T>
-void nodeContainerToOut(std::ostream& out, const T& container)
-{
- out << "[";
- bool is_first = true;
- for (const auto& item : container)
- {
- out << (!is_first ? ", " : "") << item;
- is_first = false;
- }
- out << "]";
-}
-
-}
-
/**
* Serialize a vector of nodes to given stream.
*
std::ostream& operator<<(std::ostream& out,
const std::vector<NodeTemplate<RC>>& container)
{
- nodeContainerToOut(out, container);
+ container_to_stream(out, container);
return out;
}
std::ostream& operator<<(std::ostream& out,
const std::set<NodeTemplate<RC>>& container)
{
- nodeContainerToOut(out, container);
+ container_to_stream(out, container);
return out;
}
std::ostream& out,
const std::unordered_set<NodeTemplate<RC>, hash_function>& container)
{
- nodeContainerToOut(out, container);
+ container_to_stream(out, container);
return out;
}
std::ostream& out,
const std::map<NodeTemplate<RC>, V>& container)
{
- nodeContainerToOut(out, container);
+ container_to_stream(out, container);
return out;
}
std::ostream& out,
const std::unordered_map<NodeTemplate<RC>, V, HF>& container)
{
- nodeContainerToOut(out, container);
+ container_to_stream(out, container);
return out;
}
return (match2 == last) ? match : last;
}
+template <typename T>
+void container_to_stream(std::ostream& out, const T& container)
+{
+ out << "[";
+ bool is_first = true;
+ for (const auto& item : container)
+ {
+ out << (!is_first ? ", " : "") << item;
+ is_first = false;
+ }
+ out << "]";
+}
+
}/* CVC4 namespace */
#endif /* __CVC4__UTILITY_H */