title: c++ - arbitrary void* chunk to bitset
body: <p>Suppose I have a method that receives a buffer of fixed lenght, like this:</p>
  
  <pre><code>#define SIGN_SIZE 64
  
  bitset&lt;SIGN_SIZE&gt; chunkToBitset(void * chunk);
  </code></pre>
  
  <p>Now, what I want is to create a bitset from the bits of that chunk of data (the size of the chunks is always 128 bits [16 bytes]) limited by 
  <code>SIGN_SIZE</code>, where <code>SIGN_SIZE</code> can be any value in (32, 64, 96 or 128).</p>
  
  <p>I tried to cast the chunk to unsigned long, but It does not seems to return the right value.
  Example:</p>
  
  <pre><code>unsigned long ulon = (unsigned long)* chunk;
  bitset&lt;SIGN_SIZE&gt; bs(ulon);
  </code></pre>
  
  <p>And this approach could only work when SIGN_SIZE is 64, if it is 96 it does not work.</p>
  
  <p>How can I construct the bitset with all the bits in <code>chunk</code> but respecting the limit <code>SIGN_SIZE</code>? Preferably not setting bit per bit.</p>
  
  <p>Appreciate the help!</p>