send std::string with mpi
coding, parallel | (0)
The idea is to send the size of the string first and then allocate the storage on the reciever. Here is an example with broadcast.
string s = "before";
int size = 0;
if (myRank == 0)
{
s = "after";
size = s.size();
}
BroadCast(&size,1);
if (myRank != 0) s.resize(size);
BroadCast(s.data(),size);