How to access the representation of objects ? To answer this question, I divided it into two questions:
1. How to get a pointer to the representation of an object?
According to the standard, I see no way to get a pointer to a view object. It is often suggested to do this:
some_type obj{};
const char * rep = reinterpret_cast<const unsigned char*>(&obj);
However, the standard does not say that an object and its object representation are mutually convergent. Why is this code allowed by the standard?
2. Is it possible to consider that the view object is initialized when the object is initialized?
some_type obj{};
const char * rep = reinterpret_cast<const unsigned char*>(&obj);
char x = rep[0] + rep[1];
obj
. rep[0]
, , obj
?