title: Generic way to create comparer for objects behind pointers
body: <p>I use data structures, and I sort these data structures a lot. These data structures are holding pointers to objects, not directly the objects themselves. Now I can write a simple comparison functor, or function, to tell the sort algorithm how to sort the pointers:</p>
  
  <pre><code>struct Object_ptr_comparer {
      bool operator()(const Object* first, const Object* second) {
          return *first &lt; *second;
      }
  };
  </code></pre>
  
  <p>And use for example <code>std::sort</code>:</p>
  
  <pre><code>Object_ptr_comparer comp;
  std::sort(data_str.begin(), data_str.end(), comp);
  </code></pre>
  
  <p>The only problem with this solution that I have to write extra pointer comparator functor for any type of class. Yes, I could use inheritance and polymorphism to write only the comparator of some root class, but I don't want to. Is there any other smart way to do this?</p>