title: error: no match for 'operator[]' in... <near match>
body: <p>This fail to compile in gcc 4.1.2 / RedHat 5 :</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;map&gt;
  
  class Toto {
  public:
      typedef std::string SegmentName;
  };
  
  class Titi {
  public:
      typedef Toto::SegmentName SegmentName; // import this type in our name space
      typedef std::vector&lt;SegmentName&gt; SegmentNameList;
      SegmentNameList segmentNames_;
      typedef std::map&lt;SegmentName, int&gt; SegmentTypeContainer;
      SegmentTypeContainer segmentTypes_;
  
      int getNthSegmentType(unsigned int i) const {
          int result = -1;
  
         if(i &lt; segmentNames_.size())
         {
             SegmentName name = segmentNames_[i];
             result = segmentTypes_[ name ];
         }
         return result;
      }
  };
  </code></pre>
  
  <p>The error is :</p>
  
  <pre><code>error: no match for 'operator[]' in '(...)segmentTypes_[name]'
  /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:340:
  note: candidates are: _Tp&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator[](const _Key&amp;)
  [with _Key = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, _Tp = int, _Compare = std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int&gt; &gt;]
  </code></pre>
  
  <p>Why ? The map is rather straightforward. I guess this has to do with the typedefs, but what is wrong ?
      </p>
  
  <p>[edit] Even if I remove all the <code>typedefs</code> and use <code>std::string</code> everywhere, the problem persists... Am I misusing maps ?</p>