Hello everyone, I hope this hasn't been asked before I have searched for a while now and could not find the answer to this...
The Sfml::Packet class is pretty simple and I'm trying to do something like what the class does, where I am having trouble is copying unsigned long or long long etc, I was using stf::copy but it was not working properly... I then used memcpy and it works but then I'm having trouble with the position on vector... take a look at this:
This is the Packet& operator >> (const unsigned long & data)
std::copy(&data, &data+ sizeof(data), std::back_inserter(buffer));
This is the Packet& operator >> (unsigned & long data)
std::copy(buffer[0] + pos, &buffer[0] + pos + sizeof(data), &data);
pos += sizeof(dataSize);
this work for small numbers but if I use bigger numbers it will spit random numbers....
If Laurent or anyone that has had some experience with could help me with this, that would be awesome.
the memcpy version works like this
memcpy(&buffer[0], &data, sizeof(data));
AND:
memcpy(&data, &buffer[0], sizeof(data));
But the problem is when I use the operator it is always getting buffer[0] obviously and I am stuck on how to move the pos variable accordingly, it is really late an I have been at it for a while so I know is probably simple but my brain is blocking common sense right now...