Example #1
0
	inline tDst *VirtualCast( tSrc *x )
	{
#if AX_CXX_N1836 && AX_CXX_N1720
		// We are making an important assumption here...
		static_assert( __is_base_of( tSrc, tDst ), "tSrc must be the base type of tDst" );
#endif

		// Need to know how big tDst is on its own (if it didn't inherit from tSrc)
		static const size_t diffsize = sizeof( tDst ) - sizeof( tSrc );

		// The dst address is the src address minus the dst's relative size
		const size_t srcaddr = size_t( x );
		const size_t dstaddr = srcaddr - diffsize;

		// We now have the casted address
		return reinterpret_cast< tDst * >( dstaddr );
	}
void test(bonk X) {
    X = X;
    __is_base_of(bonk, bonk);
}
Example #3
0
void f()
{
  __is_base_of(A, B);  // { dg-error "incomplete type" }
  __is_base_of(C, D);  
}