特定の構造体タイプがPODであるかどうかをテストするC++0x static_assertが必要です(他のプログラマーが誤って新しいメンバーでそれを壊さないようにするため)。すなわち、
struct A // is a POD type
{
int x,y,z;
}
struct B // is not a POD type (has a nondefault ctor)
{
int x,y,z;
B( int _x, int _y, int _z ) : x(_x), y(_y), z(_z) {}
}
void CompileTimeAsserts()
{
static_assert( is_pod_type( A ) , "This assert should not fire." );
static_assert( is_pod_type( B ) , "This assert will fire and scold whoever added a ctor to the POD type." );
}
is_pod_type()
ここで使用できるマクロまたは組み込みの種類はありますか?C ++ 0xのドキュメントでは見つかりませんでしたが、もちろん、0xに関するWebの情報はまだ断片的です。