2014-06-17から1日間の記事一覧

if(cond) と if(cond == true) は同じ意味ではない

C++

if(cond) のコンパイルは通るが、 if(cond == true) と書くとコンパイルが通らない例がある。 struct bool_ { bool value; constexpr explicit operator bool() const noexcept { return value; } }; int main() { bool_ x{true}; if (x == true) { // do so…