2007-06-10から1日間の記事一覧

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

c++

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); /</true></bool>…