Hi,
I have a bit of code where I am relying on empty base member
optimisation. The bit of code is below:
template<typena me Enum>
struct EncodePrefix
{
template<Enum e>
struct Apply
{
struct Type
{
const unsigned char Value;
Type() : Value((unsigned char)e) {}
};
};
template<>
struct Apply<(Enum)ENU M_NONE>
{
//typedef Apply Type;
struct Type {};
};
};
template<EnumRe pLockPrefix RepLockPrefix, EnumSegPrefix SegPrefix
,EnumOperandSiz ePrefix OperandSizePref ix
,EnumAddressSiz ePrefix AddressSizePref ix
,EnumSimdPrefix SimdPrefix>
struct EncodePrefixes
: EncodePrefix<En umRepLockPrefix >::Apply<RepLoc kPrefix>::Type
, EncodePrefix<En umSegPrefix>::A pply<SegPrefix> ::Type
, EncodePrefix<En umOperandSizePr efix>
::Apply<Operand SizePrefix>::Ty pe
, EncodePrefix<En umAddressSizePr efix>
::Apply<Address SizePrefix>::Ty pe
, EncodePrefix<En umSimdPrefix>:: Apply<SimdPrefi x>::Type
{
};
So when I define EncodePrefixes like this:
EncodePrefixes< NONE,NONE,NONE, NONE,NONE> ep;
I expect:
std::assert(siz eof(ep) == 1);
Unfortunately this is not the case because the msvc doesn't do empty
base member optimisation for multiple inheritance, in-case you are
wondering, sizeof(ep) == 4.
Does anyone have a work-around for which doesn't involve explicit
specialisation of the EncodePrefix class 5*2 times.
---
David