
Steven Watanabe wrote:
AMDG
niranjan bangera wrote:
union myunion {
uint32_t a; float t;
template <class Archive> void serialize(Archive & ar, const unsigned int file_version) {
ar & a; ar & t;
}
This is undefined behavior. a and t cannot both be valid at the same time.
LOL - makes me wonder if I'm even reading these emails. One could do try: struct myunion { union { uint32_t a; float t; } x; operator (uint32_t &)(){ // i forget the exact casting operator syntax return a; } operator(float &t)(){ return t; } template<class Archive> void serialize(Archive & ar, const unsigned int file_version){ ar & binary_object(sizeof(x), &x); } }; crude - but effective. Robert Ramey
In Christ, Steven Watanabe