Re: FXDir + strict aliasing?

[email protected]
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
On 2022-10-25 08:50, Sander Jansen wrote:
> Perhaps something similar like:
> https://en.cppreference.com/w/cpp/types/aligned_storage
> 


Well, it turns out, we don't even need the 'src' item in the
union, only the 'dst' item:

template <typename TOTYPE>
static inline TOTYPE* alias_cast(void* ptr){
   union UNI { TOTYPE dst[1]; };
   return reinterpret_cast<UNI*>(ptr)->dst;
   }


template <typename TOTYPE>
static inline const TOTYPE* alias_cast(const void* ptr){
   union UNI { TOTYPE dst[1]; };
   return reinterpret_cast<const UNI*>(ptr)->dst;
   }

Yes, a more perfect union!  Because now, we only have to
assume the alignment restriction of TOTYPE is met!

         -- JVZ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.