Have been reading a few strict aliasing questions, such as Cast array of bytes to POD or Aliasing `T*` with `char*` is allowed. Is it also allowed the other way around?
From these I gather that the only legal way to access a memory location declared to be any type (specifically also (array of) char
) as another type is to invoke placement new on it, as that would change the dynamic type.
Since std::aligned_storage normally has to have an underlying type other than the intended use type, it seems to me it is impossible to use the storage without invoking placement new on it first.
So I would not be allowed to create aligned_storage for, e.g. a double and use it as a double via pointer casting? Or rather, before I would be allowed to access the memory as double via pointer cast, I'd have to do a placement new on it, "turning it into" a dynamic object of type double?