title: struct with 2 cells vs std::pair?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2236182/what-is-the-difference-between-using-a-struct-with-two-fields-and-a-pair">What is the difference between using a struct with two fields and a pair?</a>  </p>
  </blockquote>
  
  
  
  <p>Dear all,</p>
  
  <p>I have a little question about pairs and struct. Is there any advantage to use a std::pair instead of a struct with two cells ?
  I have used pairs for a while but the main problem is readability :
  If you want to represent for example a duple (int "label", double "value") you can use either a  :</p>
  
  <pre><code>typedef std::pair&lt;int,double&gt; myElem;
  </code></pre>
  
  <p>or a </p>
  
  <pre><code>typedef struct {
      int label;
      double value;
  } myElem;
  </code></pre>
  
  <p>The code becomes more readable if your statements have a "semantic" sense (you will always know what x.label is. that's not the case with x.first).</p>
  
  <p>However, I guess there is an advantage using pair. Is it more performant or something else?</p>