title: How to store values returned by queue::front?
body: <p>I am a bit unsure of how to use the values returned by <code>front()</code> function from <code>std::queue</code> library. On the website cplusplus.com , it says the function returns a <strong>reference</strong>. 
  However, when I looked at the actual usages, it seems like the function is used directly to get the <strong>value</strong>. </p>
  
  <p>For example, by following these steps</p>
  
  <pre><code>std::queue&lt;int&gt; myqueue;
  myqueue.push(30);
  </code></pre>
  
  <p>The return value should be stored as follow:</p>
  
  <pre><code>int &amp;some_number  = myqueue.front();
  </code></pre>
  
  <p>So how come this is possible:</p>
  
  <pre><code>std::cout &lt;&lt; "myqueue.front() returns " &lt;&lt; myqueue.front() 
  //myqueue.front() returns 30
  </code></pre>
  
  <p>If it's returning <strong>reference</strong> to value, doesn't that mean it's returning the <strong>location</strong> where the value is stored at, and <strong>not the value itself</strong>? So how come printing the location prints out the value not the address of the integer.</p>
  
  <p>Also, following this logic, does it mean these also work?</p>
  
  <p>Scenario 1</p>
  
  <pre><code>std::queue&lt;int&gt; myqueue;
  myqueue.push(30);
  int new_number = myqueue.front();
  </code></pre>
  
  <p><code>new_number</code>'s value will be 30</p>
  
  <p>Scenario 2 - (someStruct is a defined struct)</p>
  
  <pre><code>std::queue&lt;someStruct*&gt; myqueue;
  myqueue.push(someStruct* abcPtr); \\abcPtr has been initialized 
  someStruct* edfPtr= myqueue.front();
  </code></pre>
  
  <p><code>edfPtr</code> will be pointing to the same location <code>abcPtr</code> is pointing too.</p>
  
  <p>if so, then what's the point of passing the value returned by <code>std::queue::front</code> as reference. Does anyone know the logic behind the usage? </p>