Hey, I've written a function to copy any variable type into a byte vector, however whenever I insert something it gets inserted in reverse.
Here's the code.
template <class Type>
void Packet::copyToByte(Type input, vector<uint8_t>&output)
{
copy((uint8_t*) &input, ((uint8_t*) &input) + sizeof(Type), back_inserter(output));
}
Now whenever I add for example a uint16_t with the value 0x2f1f it gets inserted as 1f 2f instead of the expected 2f 1f.
What am I doing wrong here ?
Regards, Xeross