Mat mat; cin >> mat
1234567891011121314151617181920212223242526272829303132333435
#include <iostream> #include <vector> #include <sstream> #include <string> using namespace std; struct Mat { // some other data vector<int> numbers; }; istream& operator>>(istream& is, Mat& mat) { char delim; int num; // TODO add error checking is >> delim; // read '[' while (is >> num >> delim) // until last ']' assumes end of stream mat.numbers.push_back(num); return is; } int main(int argc, char *argv[]) { istringstream iss("[128, 128, 128, 128, 128, 86, 81, 74, 69, 66, 63, 60, 57, 56, 51, 50, 48, 48, 51, 56, 60, 65, 70, 74]"); Mat mat; iss >> mat; for (int num: mat.numbers) cout << num << ' '; }