is_pod クラス
更新 : 2007 年 11 月
型が POD であるかどうかをテストします。
template<class Ty>
struct is_pod;
パラメータ
- Ty
問い合わせる型。
解説
型 Ty がスカラ型、POD 集約型、またはそのどちらかの cv-qualified 形式である場合、あるいはそのような型の配列である場合、型述語のインスタンスは true を保持します。それ以外の場合は false を保持します。
POD 集約型とは、非静的データ メンバがすべてスカラ型か POD 集約であり、参照、ユーザー定義のコピー代入演算子、およびユーザー定義のデストラクタを持たないクラス、構造体、または共用体です。
使用例
// std_tr1__type_traits__is_pod.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)
{
}
int val;
};
int main()
{
std::cout << "is_pod<trivial> == " << std::boolalpha
<< std::tr1::is_pod<trivial>::value << std::endl;
std::cout << "is_pod<int> == " << std::boolalpha
<< std::tr1::is_pod<int>::value << std::endl;
std::cout << "is_pod<throws> == " << std::boolalpha
<< std::tr1::is_pod<throws>::value << std::endl;
return (0);
}
is_pod<trivial> == true
is_pod<int> == true
is_pod<throws> == false
必要条件
ヘッダー : <type_traits>
名前空間 : std::tr1