Boost logo

Boost Users :

From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2008-05-30 07:17:09


Scott McMurray <me22.ca+boost <at> gmail.com> writes:
> std::copy( binary_buffer.begin(), binary_buffer.end(),
> reinterpret_cast<char*>(&dr) );
>

Or:
memcpy(&dr, &buffer[0], buffer.size());

Or use union to avoid making a copy:

union {
  data d;
  unsigned char bytes[4];
} u;

bytes[0] = 3;
bytes[1] = 6;
bytes[2] = 0;
bytes[3] = 9;

// use d.first, d.second, d.third

HTH,
Roman Perepelitsa.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net