carl  24.04
Computer ARithmetic Library
Serialization.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace carl::statistics {
6 
7 template<typename T, typename S>
8 inline void serialize(std::stringstream& ss, const std::pair<T,S>& pair) {
9  ss << "[" << pair.first << "," << pair.second << "]";
10 }
11 
12 template<typename T>
13 inline void serialize(std::stringstream& ss, const std::vector<T>& v) {
14  ss << carl::stream_joined(";", v);
15 }
16 
17 template<typename Key, typename Value, typename Comparator>
18 inline void serialize(std::stringstream& ss, const std::map<Key, Value, Comparator>& m) {
19  return ss << stream_joined(";", m, [](auto& o, const auto& p){ o << p.first << "=" << p.second; });
20 }
21 
22 template<typename T>
23 void serialize(std::stringstream& ss, const T& v) {
24  ss << v;
25 }
26 
27 }
auto stream_joined(const std::string &glue, const T &v)
Allows to easily output some container with all elements separated by some string.
void serialize(std::stringstream &ss, const std::pair< T, S > &pair)
Definition: Serialization.h:8