Boost logo

Boost :

Subject: Re: [boost] aligned_storage in unions
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-22 15:43:53


On Sep 22, 2010, at 2:46 PM, Mathias Gaunard wrote:

> On 22/09/2010 18:35, Larry Evans wrote:
>> How would C++0x avoid the problem?
>
> By allowing to put non-PODs in unions.
>
>
>> Could you point to the variant code violating this rule?
>
> aligned_storage<whatever>::type is a POD type of a certain type T.
> In order to read and write any of the object a variant can hold, it will need to reinterpret cast from a pointer to that object to a pointer to any of these object types, that are not necessarily the same as T.

static_cast through void*, please. That has defined behavior, whereas reinterpret_cast is only implementation-defined.

--
Dave Abrahams
BoostPro Computing
http://boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk