On 2016-04-02 16:08, Andrey Semashev wrote:
On 2016-04-02 15:45, Peter Dimov wrote:
Andrey Semashev wrote:
Thanks. I've made a patch with a similar idea:
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_
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.
Ok, I updated my pull request to implement the above version.