title: How does this implementation of bitset::count() work?
body: <p>Here's the implementation of <code>std::bitset::count</code> with MSVC 2010:</p>
  
  <pre><code>size_t count() const
      {   // count number of set bits
      static char _Bitsperhex[] = "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4";
      size_t _Val = 0;
      for (int _Wpos = _Words; 0 &lt;= _Wpos; --_Wpos)
          for (_Ty _Wordval = _Array[_Wpos]; _Wordval != 0; _Wordval &gt;&gt;= 4)
              _Val += _Bitsperhex[_Wordval &amp; 0xF];
      return (_Val);
      }
  </code></pre>
  
  <p>Can someone explain to me how this is working? what's the trick with <code>_Bitsperhex</code>?</p>