【c++11关键字】 static_assert
2020-10-29 本文已影响0人
小鱼号的代码日记
/*
* c++11关键字
* static_assert
* 编译期间判断
* 小鱼号的代码日志
*/
#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
static_assert(sizeof(int) == 4,
"only work for int for 32 bit");
static_assert(sizeof(long) == sizeof(long long),
"only work for long == long long");
return a.exec();
}