title: C++ shared_ptr equality operator
body: <p>The equality operator for shared_ptr's is defined as follows:</p>
  
  <pre><code>template&lt;class T, class U&gt; inline bool operator==(
      shared_ptr&lt;T&gt; const &amp; a, shared_ptr&lt;U&gt; const &amp; b)
  {
      return a.get() == b.get();
  }
  </code></pre>
  
  <p>This seems broken. Would it not have been better to forward the equality to what a and b 
  are pointing to? Or would that be an unfair restriction on users of the library (in that
  they have to provide an equality operator) ?</p>
  
  <p>If I have a map or a hash_table containing shared_ptrs, then the current definition
  makes equality unusable. For example, consider</p>
  
  <pre><code>std::map&lt;int, std::tr1::shared_ptr&lt;T&gt; &gt; m1, m2;
  </code></pre>
  
  <p>Won't we want to check that the ptrs for each int in m1 and m2 are pointing to the same value ? </p>
  
  <p>I can implement my own equality by flattening m1, m2 out (constructing sets from each,
  dereferencing shared_ptrs along the way). Is there an STL trick that will accomplish this
  or some other way to test equality in the presence of shared_ptrs neatly ?</p>