シンプルなコンパイル時アサート

template<bool> struct StaticErrorChecker;
template<> struct StaticErrorChecker<true>{};

#define STATIC_ASSERT(expr) (StaticErrorChecker<(expr) != 0>()) 


int main(){
	const bool true_flag = true;
	const bool false_flag = false;

	STATIC_ASSERT(true_flag); //ok

	STATIC_ASSERT(false_flag); //error
}

参考:Modern C++ Design