"taking address of temporary" warning
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8324699/taking-address-of-temporary-while-accessing-address-of-a-element-in-vectorbool">taking address of temporary while accessing address of a element in vector&lt;bool&gt;</a>  </p>
</blockquote>



<p>I get 'taking address of temporary' warning at line 7 in following piece of code<br/>  </p>

<pre><code>1    vector&lt;bool&gt; boolVect;&lt;br/&gt; 
2    bool x = true;&lt;br/&gt; 
3    boolVect.push_back(true);&lt;br/&gt; 
4    boolVect.push_back(false);&lt;br/&gt; 
5    ofstream fMetaOut("tmp.txt", ios::out);&lt;br/&gt;
6    fMetaOut.write((char* )&amp;x, sizeof(bool));&lt;br/&gt;  
7    fMetaOut.write((char* )&amp;boolVect[0], sizeof(bool));&lt;br/&gt;
8    fMetaOut.close();
</code></pre>

<p>Why do I get this warning at line 7 and not at 6 ??
Both use boolean address. <br/>
How can I get rid of this warning?</p>
