title: Using a vector < pair < string, int > > to represent a hash table
body: <p>I am trying to represent a hash table as a vector of pair &lt; string, int>. I am using a hash function to return the value of the index of the vector where I wish to place the pair.  I have been able to successfully create a pair and index the pair's string with the hash function.  Now that I know where I want to place my pair in my vector I try to put it there but my program has a segmentation fault at this point.
  My hash function:</p>
  
  <pre><code>size_t hashfunction(const string&amp; ident){
      unsigned hash = 0;
      for(int i = 0; i &lt; ident.size(); ++i) {
         char c = ident[i];
         hash ^= c + 0x9e3779b9 + (hash&lt;&lt;6) + (hash&gt;&gt;2);
      }
      return hash;
  }
  </code></pre>
  
  <p>My main function:</p>
  
  <pre><code>int main(){
      vector &lt; pair &lt; string, int &gt; &gt; hashtable;
      pair &lt;string, int&gt; testone ("bartering", 5);
  
      size_t testoneindex = hashfunction(testone.first);
      hashtable[testoneindex] = testone;
      return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>This section of code compiles but produces a segmentation fault at the line</p>
  
  <pre><code>hashtable[testoneindex] = testone;
  </code></pre>
  
  <p>What am I doing wrong?</p>