title: How to NOT overload the std::map::at member function in the case where the two template types are the same?
body: <p>I have a here a bidirectional map. I make it form 0. I defined member functions like <code>insert</code> <code>count</code> <code>size</code> and others and of course a function <code>at</code> which returns a reference to the mapped value of the element identified with the given key. Until type A is not the same with type B everything works fine, but when type A is the same with type B i get an error that i try to overload this function <code>at</code>, which is correct :( But my mind can`t help me with a method to solve this error. Maybe you can give me an example or tell me what i can do in this case :)</p>
  
  <pre><code>template &lt;class A,class B&gt;
  
  class BidirectionalMap
  {
  public:
      void insert(A a,B b)
      {
          m1.insert(std::pair&lt;A,B&gt; (a,b));
          m2.insert(std::pair&lt;B,A&gt; (b,a));
      }
      BidirectionalMap&amp; operator =(BidirectionalMap &amp;a)
      {
          m1=a.m1;
          m2=a.m2;
          return *this;
      }
      A&amp; at(const A&amp; a)
      {
          if(m1.find(a)!=m1.end()) return m1.at(a);
          else return m2.at(a);
      }
      const B&amp; at(const A&amp; b) const
      {
          return m1.at(b);
      }
      const A&amp; at(const B&amp; a) const
      {
          return m2.at(a);
      }
      int size() const
      {
          return m1.size();
      }
      int count(const A&amp; a) const
      {
          return m1.count(a);
      }
      int count(const B&amp; b) const
      {
          return m2.count(b);
      }
      B&amp; operator[](const A&amp; a)
      {
          return m1[a];
      }
      A&amp; operator[](const B&amp; b)
      {
          return m2[b];
      }
  private:
      std::map&lt;A,B&gt; m1;
      std::map&lt;B,A&gt; m2;
  };
  </code></pre>
  
  <p>And what if i cannot modify this sequence in main()?</p>
  
  <pre><code>  BidirectionalMap&lt;int, int&gt; f;
    f.insert(3, 18);
    f.insert(8, 2);
    f.insert(7, 5);
    f.insert(9, 1);
    const BidirectionalMap&lt;int, int&gt; cf = f;
  
    if( f.at(5) == 7 &amp;&amp;
        f.count(12) == 0 &amp;&amp;
        f.at(8) == 2)
    {
      yourMark = cf[18] + cf[9];
    }
  </code></pre>