Boost logo

Boost :

Subject: Re: [boost] [function] Placement new warnings from gcc 6
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2016-04-02 09:08:28


On 2016-04-02 15:45, Peter Dimov wrote:
> Andrey Semashev wrote:
>
>> Thanks. I've made a patch with a similar idea:
>>
>> https://github.com/boostorg/function/pull/9
>
> This works, although the following alternative:
>
> template<class T> union function_buffer_
> {
> // as before
> mutable T data;
> };
>
> size_t const function_buffer_size = sizeof(function_buffer_<char>);
>
> typedef function_buffer_<char[function_buffer_size]> function_buffer;
>
> seems slightly more maintainable as it doesn't perform the size
> computation separately.

That instantiates the template twice, maybe it'll affect compile times.
Also, I'm a bit cautious about using an array type in template
parameters - maybe it'll cause trouble on ancient compilers?

I guess, I could extract all members other than 'data' to a separate
union and then:

   union function_buffer
   {
     mutable function_buffer_members m;
     mutable char data[sizeof(function_buffer_members)];
   };

This would require more modifications to the code though.

(Sigh... if only we could inherit unions...)


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