21 #ifndef mia_core_svector_hh
22 #define mia_core_svector_hh
40 std::ostream&
operator << (std::ostream& os,
const std::vector<T>& v)
56 static bool apply(
const std::string& str, T& v)
59 std::istringstream s(str);
65 while (!s.eof() && s.peek() ==
' ')
74 static bool apply(
const std::string& s, std::string& str)
83 std::istream&
operator >> (std::istream& is, std::vector<T>& v)
85 std::vector<T> values;
89 while (std::getline(is, token,
',')) {
91 values.push_back(val);
93 throw create_exception<std::invalid_argument>(
"Reading vector: value, '", token,
94 "' could not be translate to ",
95 mia::__type_descr<T>::value);
99 if (!v.empty() && v.size() != values.size()) {
100 throw create_exception<std::invalid_argument>(
"Reading vector: expected ",
101 v.size(),
" values, but got ", values.size());