title: How to define a multiset using a function pointer?
body: <p>I'm  stuck when doing an exercise from <em>C++ Primer 5th Edition</em> ,which goes like</p>
  
  <blockquote>
    <p>Exercise 11.11: Redefine bookstore without using decltype.</p>
  </blockquote>
  
  <p>Below is the relevant codes in this book:</p>
  
  <pre><code>multiset&lt;Sales_data, decltype(compareIsbn)*&gt; bookstore(compareIsbn);
  </code></pre>
  
  <p>The code for class Sales_data is a little bit verbose to post here,so I wrote a simpler one and defined the multiset in the same style, as shown below. It compiled without any error.</p>
  
  <pre><code>class A
  {
      int lenth;
  public:
      int getLenth() const {return lenth;}
  };
  
  bool compareA(const A &amp;a1, const A &amp;a2)
  {
      return a1.getLenth() &lt; a2.getLenth();
  }
  
  int main()
  {
      std::multiset&lt;A, decltype(compareA)*&gt; m1(compareA);
      return 0;
  }
  </code></pre>
  
  <p>I guess this exercise want readers to review knowledge of function pointers, so I tried another way to define it. But it doesn't work. Below is where I'm stuck</p>
  
  <pre><code>int main()
  {
      bool (*fp) (const A &amp;a1, const A &amp;a2);
      fp = &amp;compareA;
  
      std::multiset&lt;A, fp*&gt; m1(fp);
  
      return 0;
  }
  </code></pre>
  
  <p>Three errors were generated:</p>
  
  <pre><code>error: template argument 2 is invalid
  error: invalid type in declaration before '(' token
  error: invalid conversion from 'bool (*)(const A&amp;, const A&amp;)' to 'int' [-fpermissive]
  </code></pre>
  
  <p>What's my problem?How to fix it?</p>