On 07/22/2014 02:34 PM, Richard Biener wrote:
As discussed during the Cauldron keeping some builtin doesn't help because you are not forced to access the newly created object via the pointer returned by the placement new. That is,template <T> struct Storage { char x[sizeof(T)]; Storage() { new (x) T; } T& get() { return reinterpret_cast <T&> (x); } }; is valid
Yes.
(and used in this way in Boost - with a type different from 'char' to force bigger alignment).
But I don't think that should be valid, unless the type contains a char array at offset 0, as {std,boost}::aligned_storage; the C++ standard needs improvement in this area.
Looks like the small buffer optimization in boost::spirit::hold_any would need to be tweaked, as it uses a void* to store anything the same size or smaller, but that's the only dodgy case I see.
Jason
