title: Initializing very large C++ std::bitset at compile time
body: <p>I want to store a static constant bitset of 2<sup>16</sup> bits, with a specific sequence of 1s and 0s that never changes.</p>
  <p>I thought of using an initializer string as proposed by <a href="https://stackoverflow.com/questions/41753330/initializing-c-stdbitset-at-compile-time">this post</a> :</p>
  <pre><code>std::bitset&lt;1&lt;&lt;16&gt; myBitset(&quot;101100101000110 ... &quot;); // the ellipsis are replaced by the actual 65536-character sequence
  </code></pre>
  <p>But the compiler (VS2013) gives me the <a href="https://stackoverflow.com/questions/16868362/c-string-too-big-trailing-characters-truncated">&quot;string too long&quot;</a> error.</p>
  <p><strong>UPDATE</strong></p>
  <p>I tried splitting the string into smaller chunks, as proposed in the post linked above, like so:</p>
  <pre><code>std::bitset&lt;1&lt;&lt;16&gt; myBitset(&quot;100101 ...&quot;
                              &quot;011001 ...&quot;
                              ...
                              );
  </code></pre>
  <p>But I get the error <em><strong>C1091: compiler limit: string exceeds 65535 bytes in length</strong></em>. My string is 65536 bytes (well technically 65537, with the EOS character).</p>
  <p>What are my other options?</p>
  <p><strong>UPDATE</strong></p>
  <p>Thanks to <a href="https://stackoverflow.com/users/1133179/luk32">luk32</a>, this is the beautiful code I ended up with:</p>
  <pre><code>const std::bitset&lt;1&lt;&lt;16&gt; bs = (std::bitset&lt;1&lt;&lt;16&gt;(&quot;101011...&quot;)
      &lt;&lt; 7* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;110011...&quot;)
      &lt;&lt; 6* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;101111...&quot;)
      &lt;&lt; 5* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;110110...&quot;)
      &lt;&lt; 4* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;011011...&quot;)
      &lt;&lt; 3* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;111011...&quot;)
      &lt;&lt; 2* (1&lt;&lt;13)) | (std::bitset&lt;1&lt;&lt;16&gt;(&quot;111001...&quot;)
      &lt;&lt; 1* (1&lt;&lt;13)) | std::bitset&lt;1&lt;&lt;16&gt;(&quot;1100111...&quot;);
  </code></pre>