Boost logo

Boost :

Subject: Re: [boost] Another variant type (was: [peer review queue tardiness] [was Cleaning out the Boost review queue] Review Queue mem
From: Larry Evans (cppljevans_at_[hidden])
Date: 2015-04-09 13:36:58

On 04/08/2015 08:14 AM, Larry Evans wrote:
> On 04/04/2015 07:55 PM, Eric Niebler wrote:
>> On 4/4/2015 4:42 PM, Larry Evans wrote:
>>> On 04/04/2015 06:25 PM, Steven Watanabe wrote:
>>>> AMDG
>>>> On 04/04/2015 05:20 PM, Larry Evans wrote:
>>>>> On 04/04/2015 06:18 PM, Steven Watanabe wrote:
>>>>>> The reason that aligned storage doesn't work has nothing to
>>>>>> do with calculating the alignment.
>>>>> Why does using aligned_storage not work, please?
>>>> On 04/04/2015 04:06 PM, Matt Calabrese wrote:
>>>>> You need to use a recursive union if you are to get some
>>>>> constexpr support.
>>> OK. So Matt, could you please elaborate on why constexpr support
>>> requires a recursive union?
>> To put an object into aligned storage requires placement new, which is
>> not constexpr. Using a recursive union avoids the need for placement new.
> Thanks Eric.
> I see the restriction about new expression here:
> I can see how a new expression which is not a placement new
> would be disallowed; however, I don't see a reason why
> placement new would be disallowed when the void* 2nd argument
> is a pointer to a constexpr aligned_union member variable.
> Could you please provide a reference or explanation of why
> placement new is not allowed in a constexpr?
It's not just the new expression limitation. The static_cast
from void const* is not allowed either, and that's also
required, AFAICT, in the aligned_union implementation of variant.
Attached is code which illustrates both limitations.
#define USE_PLACEMENT_NEW to show the 1st limitation.
#define USE_STATIC_CAST_VOID to show the 2nd limitation.
The code was compiled with clang 3.5.


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