cast to a pointer of the referance, not the value
This commit is contained in:
parent
34bcd7b174
commit
bc36227387
|
@ -109,7 +109,7 @@ struct Message
|
|||
* @param val
|
||||
*/
|
||||
template<typename T>
|
||||
static void writeType(std::vector<uint8_t>& data, T val)
|
||||
static void writeType(std::vector<uint8_t> &data, const T val)
|
||||
{
|
||||
if (val == 0)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ struct Message
|
|||
data.push_back(0);
|
||||
return;
|
||||
}
|
||||
auto raw = reinterpret_cast<uint8_t*>(val);
|
||||
auto raw = reinterpret_cast<const uint8_t*>(&val);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
data.push_back(raw[i]);
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ private:
|
|||
void writeDiscBranch(std::vector<uint8_t> &data) const;
|
||||
|
||||
template<typename T>
|
||||
uint16_t addSum_(uint16_t sum, T val) const
|
||||
uint16_t addSum_(uint16_t sum, const T val) const
|
||||
{
|
||||
uint16_t carry;
|
||||
auto raw = reinterpret_cast<uint8_t*>(val);
|
||||
auto raw = reinterpret_cast<const uint8_t*>(&val);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
{
|
||||
uint8_t num = raw[i];
|
||||
|
|
Loading…
Reference in New Issue