Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-10-02 19:58:40

on Tue Oct 02 2007, Sebastian Redl <> wrote:

> The implicit guarantee is there because there is no other way to convert
> the pointer except through a reinterpret_cast. (A C-style cast is
> defined in terms of the cast operator is takes the place of.)
> Layout compatibility is not mentioned anywhere else. So what does that mean?
> It means that, by the words of the standard, your code was not valid. On
> the other hand, making both structs the members of a union, then
> assigning one and reading the other, is valid. Make of that what you will.

If you want to make it valid, replace reinterpret_cast<X*>(a) with

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at