のWindows SDKは、型定義のセットが含まれています。そして、POINT
構造体の配列とその配列の長さへのポインタを期待するWinAPIの機能がありますこれはRECTとPOINTの間のreinterpret_castセーフですか?
typedef long LONG;
typedef struct tagPOINT
{
LONG x;
LONG y;
} POINT;
typedef struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
:
void ThatFunction(POINT* points, int numberOfElements);
と我々が持っています以下のコード:
RECT rect = ...//obtained from somewhere
ThatFunction(reinterpret_cast<POINT*>(&rect), 2);
RECT
は2のアレイとして扱われているように構造体。
キャストは安全ですか?
C++のstatic_assert()での良い例として+1。 –