title: std::map insert error: no operator "<" matches these operands
body: <p>Trying to brush up on my C++ and STL proficiency, running into a problem with std::map keyed by a structure I've defined. Relevant code:</p>
  
  <pre><code>typedef struct key_t {
     int a;
     int b;
     bool operator==(const key_t&amp; rhs)
     {
        return (a == rhs.a) &amp;&amp; (b == rhs.b);
     }
     bool operator&lt;(const key_t&amp; rhs) //added the when I saw this error, didn't help
     {
        return a &lt; rhs.a;
     }
  } key_t;
  
  std::map&lt;key_t, int&gt; fooMap;
  
  void func(void)
  {
      key_t key;        
      key.a = 1;
      key.b = 2;
  
      fooMap.insert(std::pair&lt;key_t, int&gt;(key, 100));
  }
  </code></pre>
  
  <p>Error looks like this:</p>
  
  <pre><code>"/opt/[redacted]/include/functional", line 133: error: no operator "&lt;" matches these operands
              operand types are: const key_t &lt; const key_t
            detected during:
              instantiation of "bool std::less&lt;_Ty&gt;::operator()(const _Ty &amp;, const _Ty &amp;) const [with _Ty=key_t]" at line 547 of "/opt/[redacted]/include/xtree"
  instantiation of "std::_Tree&lt;_Traits&gt;::_Pairib std::_Tree&lt;_Traits&gt;::insert(const std::_Tree&lt;_Traits&gt;::value_type &amp;) [with _Traits=std::_Tmap_traits&lt;key_t, UI32, std::less&lt;key_t&gt;, std::allocator&lt;std::pair&lt;const key_t, UI32&gt;&gt;, false&gt;]"
  </code></pre>
  
  <p>What am I doing wrong? Is it just flat-out awful/impossible to use structures as a map key? Or something else I'm overlooking?</p>