|
Boost : |
Subject: Re: [boost] [forward_declare] Interest Inquiry toward Faster Compile Times
From: Sergey Cheban (s.cheban_at_[hidden])
Date: 2012-08-02 01:59:37
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk