
2 Aug
2012
2 Aug
'12
5:59 a.m.
02.08.2012 8:28, Daniel Larimer пишет:
Yes, _store[S] has an alignment requirement of 1, but what is the alignment requirement for fwd<T,S>? It's probably 1 because _store has an alignment of 1.
Btw, what about the following? template<typename T, size_t S, typename Alignment1=char, typename Alignment2=char, typename Alignment3=char> struct fwd { fwd() { static_assert( sizeof(*this) >= sizeof(T), "!" ); new (this) T(); } union { char _store[S]; Alignment1 _alignment1; Alignment2 _alignment2; Alignment3 _alignment3; }; }; MSVC compiler has also an __alignof operator. -- Best regards, Sergey Cheban