There are several ways to detect this at run-time but I cannot find a way to determine if a pointer to a class will be offsetted at compile-time.
class MyA
{
public:
int m_memberI;
};
class MyB
{
public:
double m_memberD;
};
class MyC : public MyA, public MyB
{
};
void main()
{
MyC myC;
void* pVoidB = dynamic_cast< MyB* >( &myC );
if( pVoidB != &myC )
{
std::cout << "Offset needed!" << std::endl;
}
}
// **********************************************************************************
// Ideally, I would prefer something like this
//
// static_assert( std::cast_needs_offset< MyB*, MyC* >::value, "Offset detected!!!" );
// **********************************************************************************
The compilers obviously has that information, but I can't find a type_trait that could help me.
Any trick up your sleeves?