This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix std::experimental::any for small, non-trivial objects


On 02/05/15 19:05 +0200, Daniel Krügler wrote:
Not related to the patch, but is the second template argument of
any::_Storage::_M_buffer really correct:

std::aligned_storage<sizeof(_M_ptr), sizeof(_M_ptr)>::type _M_buffer;

I would have expected to see this to be an alignment value.

Yes, that looks like a typo.

We could remove that second argument completely, although that might
increase the alignment requirements on any (probably not in practice).

Looking at it now, I think the _Internal alias template should also
check that alignof(_Tp) <= alignof(void*) so that it can safely be
stored in the _Storage.


Otherwise a type with sizeof(T) <= sizeof(void*) but
alignof(T) > alignof(void*) would not be correctly aligned when stored
in the buffer.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]