title: write std::bitset to binary file and load the file to std:bitset
body: <p>I am working with a project which will use bitset. As the text file  provided is very large(>800M), to load it directly to std::bitset will cost more then 25 seconds. So I want to preprocess the text file to a memory dumped binary file. 
  Because a char with 8 bit will covert to 1 bit, the cost time of file load will reduce much. I write a demo code:</p>
  
  <pre><code>#include &lt;iostream&gt;      
  #include &lt;bitset&gt;         
  #include &lt;string&gt;
  #include &lt;stdexcept&gt;      
  #include &lt;fstream&gt;
  #include &lt;math.h&gt; 
  
  int main () {
      const int MAX_SIZE = 19;
      try {
  
          std::string line = "1001111010011101011";
          int copy_bypes = (int)ceil((float)MAX_SIZE / 8.0);
  
  
          std::bitset&lt;MAX_SIZE&gt;* foo = new (std::nothrow)std::bitset&lt;MAX_SIZE&gt;(line);     // foo: 0000
          std::ofstream os ("data.dat", std::ios::binary);
          os.write((const char*)&amp;foo, copy_bypes);
          os.close();
  
  
          std::bitset&lt;MAX_SIZE&gt;* foo2 = new (std::nothrow)std::bitset&lt;MAX_SIZE&gt;();
          std::ifstream input("data.dat",std::ios::binary);
          input.read((char*)&amp;foo2, copy_bypes);
          input.close();
  
          for (int i = foo2-&gt;size() -1 ; i &gt;=0 ; --i) {
              std::cout  &lt;&lt; (*foo2)[i];
          }
          std::cout &lt;&lt;std::endl;
      }
      catch (const std::invalid_argument&amp; ia) {
          std::cerr &lt;&lt; "Invalid argument: " &lt;&lt; ia.what() &lt;&lt; '\n';
      }
      return 0;
  }
  </code></pre>
  
  <p>it seems work fine, but I am worried this usage can really work fine in production enviroment. </p>
  
  <p>Thanks in some advanced.</p>