Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-04-26 20:07:19


On Thu, Apr 26, 2012 at 4:45 PM, Mathias Gaunard <
mathias.gaunard_at_[hidden]> wrote:

> On 26/04/12 23:08, Peter Dimov wrote:
>
>> Mathias Gaunard wrote:
>>
>>> On 26/04/12 22:08, Jeffrey Lee Hellrung, Jr. wrote:
>>>
>>> > Doesn't the same thing happen in boost::optional and boost::variant?
>>>
>>> Yes, their code is arguably ill-formed, but I'm sure some people claim
>>> otherwise.
>>>
>>
>> No, it's not. Provide the standard text that, in your opinion, makes
>> them ill-formed.
>>
>
> 3.10/10.
>
> If a program attempts to access the stored value of an object through a
> glvalue of other than one of the following types the behavior is undefined:
>
> — the dynamic type of the object,
> — a cv-qualified version of the dynamic type of the object,
> — a type similar (as defined in 4.4) to the dynamic type of the object,
> — a type that is the signed or unsigned type corresponding to the dynamic
> type of the object,
> — a type that is the signed or unsigned type corresponding to a
> cv-qualified version of the dynamic type
> of the object,
> — an aggregate or union type that includes one of the aforementioned types
> among its elements or non-
> static data members (including, recursively, an element or non-static data
> member of a subaggregate
> or contained union),
> — a type that is a (possibly cv-qualified) base class type of the dynamic
> type of the object,
> — a char or unsigned char type.
>
> I suppose you probably want to say that the type you're accessing the
> object with is actually the dynamic type of the object, but that idea is
> not supported anywhere in the standard.
>

You can safely static_cast a void pointer to a pointer of the dynamic type
of the object the void pointer points.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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