title: Can I check a small array of bools in one go?
body: <p>There was a similar question <a href="https://stackoverflow.com/questions/4044590/can-i-check-in-c-if-an-array-is-all-0-or-false">here</a>, but the user in that question seemed to have a much larger array, or vector. If I have:</p>
  
  <pre><code>bool boolArray[4];
  </code></pre>
  
  <p>And I want to check if all elements are false, I can check [ 0 ], [ 1 ] , [ 2 ] and [ 3 ] either separately, or I can loop through it. Since (as far as I know) false should have value 0 and anything other than 0 is true, I thought about simply doing:</p>
  
  <pre><code>if ( *(int*) boolArray) { }
  </code></pre>
  
  <p>This works, but I realize that it relies on bool being one byte and int being four bytes. If I cast to (std::uint32_t) would it be OK, or is it still a bad idea? I just happen to have 3 or 4 bools in an array and was wondering if this is safe, and if not if there is a better way to do it.</p>
  
  <p>Also, in the case I end up with more than 4 bools but less than 8 can I do the same thing with a std::uint64_t or unsigned long long or something?</p>