21 #ifndef mia_core_svector_hh
22 #define mia_core_svector_hh
40 std::ostream&
operator << (std::ostream& os,
const std::vector<T>& v) {
53 static bool apply(
const std::string& str, T& v){
55 std::istringstream s(str);
59 while (!s.eof() && s.peek() ==
' ')
67 static bool apply(
const std::string& s, std::string& str){
75 std::istream&
operator >> (std::istream& is, std::vector<T>& v)
77 std::vector<T> values;
81 while(std::getline(is, token,
',')) {
83 values.push_back(val);
85 throw create_exception<std::invalid_argument>(
"Reading vector: value, '", token,
86 "' could not be translate to ",
87 mia::__type_descr<T>::value);
91 if (!v.empty() && v.size() != values.size()) {
92 throw create_exception<std::invalid_argument>(
"Reading vector: expected ",
93 v.size(),
" values, but got ", values.size());