Ada 编程/属性/'Tag
外观
X'Tag 是一个 Ada 属性,其中 X 是任何 带标签类型。此属性返回私有类型 Ada.Tags.Tag 的值,该值标识带标签类型。
此属性对于检查类型在类层次结构中的成员资格很有用。如果已知类型位于类层次结构中并且必须进行类型特定的处理,也可以使用它。
Ref : My_Tagged_Type_Reference; ...ifRef.allinMy_Tagged_Type'Classthen-- The object pointed at by Ref is in class hierarchy that is rooted at My_Tagged_Type.ifRef.all'Tag = My_Tagged_Type'Tagthen-- Object is of type My_Tagged_Type.else-- Object is of some other type in the hierarchy.endif;else-- Object is not in the class hierarchy rooted at My_Tagged_Type (it might be of a progenitor type though).endif;
