I have the following struct:
struct msg_latency{
double time;
string data;
};
I have a vector of strings which contains strings like: "2344.5435345 hello world\n:"
I have to iterate the vector of the strings and convert each string to msg_latency struct.
vector<msg_latency> vec_msg
convert_str2struct(vector<string> str_vec, vector<msg_latency> msg_vec)
{
vector<string>::iterator msg_it;
for(msg_it=str_vec.begin(); msg_it!= str_vec.end(); ++msg_it)
{
///TODO
}
}
While in the todo I want to write something like:
msg_vec[i].time= *msg_it.substr(0, *msg_it.find(" "));
msg_vec[i].data= *msg_it;
How can I initialize the msg_vec as I describred above?
Can I do something like (in the TODO):
msg_vec.push_back({*msg_it.substr(0, *msg_it.find(" ")), *msg_it})
?