本文介绍了typeid运算符返回的对象的生存期是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我呼叫typeid
并检索返回的type_info
的地址:
If I call typeid
and retrieve the address of returned type_info
:
const type_info* info = &( typeid( Something ) );
typeid
返回的对象的生存期是多少?指向该对象的指针将保持多长时间?
what's the lifetime of the object returned by typeid
and how long will the pointer to that object remain valid?
推荐答案
无论实现如何实现,typeid
表达式的结果都是左值,并且这些左值所引用的对象的生存期必须持续到操作结束.程序.
However the implementation implements them, the results of typeid
expressions are lvalues and the lifetime of the objects that those lvalues refer to must last until the end of the program.
根据ISO/IEC 14882:2003 5.2.8 [expr.typeid]:
From ISO/IEC 14882:2003 5.2.8 [expr.typeid]:
这篇关于typeid运算符返回的对象的生存期是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!