title: How to make my "own" templated map?
body: <p>I want to implement my own "simple" container which will have map properties but also keeps insertion order. I've heard about boost::multi_index but I find it very difficult to understand for what I want.</p>
  
  <p>So I made a templated class:</p>
  
  <pre><code>template&lt;typename KEY, typename VALUE&gt;
  class MyMap {
      private : 
          std::vector&lt;KEY&gt;    m_keys;
          std::vector&lt;VALUE&gt;  m_values;
  
      public :
          void insert(KEY&amp; key, VALUE&amp; val) {
              //Test if key exists //
              m_keys.push_back(key);
              m_values.push_back(val);
          }
  
          /* Other methods like erase/size/operator[]/begin/etc. */
  
  };
  </code></pre>
  
  <p>Just to test it, I wanted to do something like this:</p>
  
  <pre><code>int main() {
      MyMap&lt;string,int&gt; m;
      m.insert("test",1);
      m.insert("cat",2);
  
      for(auto&amp; item : m) {
          cout &lt;&lt; item &lt;&lt; endl;
          cout &lt;&lt; m[item] &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>But I keep getting a compilation error on inserts (and [ ]) as it translates my KEY into a basic_string and not a string. It's driving me crazy and I can't find any answer (or any word to properly describe my problem to research for an answer). I guess it has something to do with allocators but I can't manage to understand how to fix it.
  How can I make my map do this conversion but also stays general as I will need it with other (own-implemented) classes?</p>
  
  <p><strong>EDIT :</strong> After solving "string" problem, I had problems when passing int because it was waiting for an &amp;int. Followed kebs advice and implemented a vector> instead and got rid of conversion problems... :)</p>