What is the best way in C++ to go about the following:
struct somethingParams mParams;
memcpy(&mParams, rcvbuf.data(), sizeof(somethingParams));
rcvbuf.erase(rcvbuf.begin(), rcvbuf.begin + sizeof(somethingParams));
From what I've read, memcpy is not recommended in C++. I understand that it is "C-style". I'm using C++ 11. Is there a better way to achieve what I am doing? ie. Copying data from a vector into a struct.
Just see-ing if I can make it more "C++".
Thanks.
Aucun commentaire:
Enregistrer un commentaire