is_polymorphic 类
测试类型是否包含虚函数。
语法
template <class Ty>
struct is_polymorphic;
参数
Ty
要查询的类型。
备注
如果类型 Ty 是声明或继承虚函数的类,则类型谓词的实例为 true;否则为 false。
示例
// std__type_traits__is_polymorphic.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
struct throws
{
throws() throw(int)
{
}
throws(const throws&) throw(int)
{
}
throws& operator=(const throws&) throw(int)
{
}
virtual ~throws()
{
}
int val;
};
int main()
{
std::cout << "is_polymorphic<trivial> == " << std::boolalpha
<< std::is_polymorphic<trivial>::value << std::endl;
std::cout << "is_polymorphic<throws> == " << std::boolalpha
<< std::is_polymorphic<throws>::value << std::endl;
return (0);
}
is_polymorphic<trivial> == false
is_polymorphic<throws> == true
要求
标头:<type_traits>
命名空间: std
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈