Efficiently reading and writing mixed data types in C++-11 : <p>Efficient way of writing and reading mixed datatypes (viz. unsigned integer, double, uint64_t, string) on file in c++.</p>

<p>I need to write and read a data containing mixed data-types on disk. I used the following method to write data. However it is turning out to be very slow. </p>

<pre><code>fstream myFile;
myFile.open("myFile", ios::binary, ios::out);
double x; //with appropriate initialization
myFile&lt;&lt;x;
int y;
myFile&lt;&lt;y;
uint64_t z;
myFile&lt;&lt;z;
string myString;
myFile&lt;&lt;myString;
</code></pre>

<p>However, this method is turning out to be very inefficient for large data of size 20 GB. Can someone please suggest as to how I can quickly read and write mixed datatypes in c++</p>
