__RTDynamicCast__RTDynamicCast

dynamic_cast 运算符的运行时实现。Runtime implementation of the dynamic_cast operator.

语法Syntax

PVOID __RTDynamicCast (  
   PVOID inptr,   
   LONG VfDelta,  
   PVOID SrcType,  
   PVOID TargetType,   
   BOOL isReference  
   ) throw(...)  

参数Parameters

inptr
指向多态对象的指针。Pointer to a polymorphic object.

VfDelta
对象中的虚函数指针的偏移量。Offset of virtual function pointer in object.

SrcType
inptr 参数指向的对象的静态类型。Static type of object pointed to by the inptr parameter.

TargetType
转换的预期结果。Intended result of cast.

isReference
如果输入是引用,则为 true;如果输入是指针,则为 falsetrue if input is a reference; false if input is a pointer.

返回值Return Value

如果成功,则为指向适当的子对象的指针;否则为 NULL。Pointer to the appropriate sub-object, if successful; otherwise, NULL.

异常Exceptions

如果 bad_cast() 的输入为引用并且转换失败,则为 dynamic_cast<>bad_cast() if the input to dynamic_cast<> is a reference and the cast fails.

备注Remarks

inptr 转换为 TargetType 类型的对象。Converts inptr to an object of type TargetType. 如果 TargetType 是指针,则 inptr 类型必须为指针,或者如果 TargetType 是引用,则为左值。The type of inptr must be a pointer if TargetType is a pointer, or an l-value if TargetType is a reference. TargetType 必须是针对以前定义的类类型的指针或引用,或者是指向 void 的指针。TargetType must be a pointer or a reference to a previously defined class type, or a pointer to void.

要求Requirements

例程Routine 必需的标头Required header
__RTDynamicCast__RTDynamicCast rtti.hrtti.h