一个模板元在编译时候检查版本结构的功能

    技术2022-05-19  19

    template < bool > struct SizeGuard { private: SizeGuard() {} };  //这里定义好通常结构 template <> struct SizeGuard < true > { SizeGuard( LPCSTR ) {} }; // 这里设置好条件 // 之前结构写错,现在只能保持这个错误了. static SizeGuard< sizeof( SPlayerExpand ) == 4104 >   // 当条件为false时,进入SizeGuard(),则下面的ck1必然失效 ck1( "正在检测SPlayerExpand的数据结构大小" );


    最新回复(0)