bbool型におけるビット演算の挙動を調べるプログラム
#include <iostream>
using namespace std;
int main(int argc, char const* argv[]){
bool ands[4] = {true & true, true & false, false & true, false & false};
bool ors[4] = {true | true, true | false, false | true, false | false};
cout << "ands: ";
for (int i = 0; i < 4; i++) cout << std::boolalpha << ands[i] << " ";
cout << endl;
cout << "ors: ";
for (int i = 0; i < 4; i++) cout << std::boolalpha << ors[i] << " ";
cout << endl;
bool and_substitute = true; and_substitute &= false;
bool or_substitute = true; or_substitute |= false;
cout << "and_substitute: " << std::boolalpha << and_substitute << endl;
cout << "or_substitute: " << std::boolalpha << or_substitute << endl;
return 0;
}