mercredi 20 décembre 2017

Append structs to a vector

I'm writing a message comuniction lib, and need to read some data to a struct, and append this struct to a vector, and read again, append again.

If in C language, memcpy works perfect, but I want is to make all code in C++11 code style.

I tried to use std::copy, but it needs a begin and end interator, so how exactly I can use std::copy like std::copy(&a, &a + sizeof(A), back_inserter(buffer));?

Aucun commentaire:

Enregistrer un commentaire