title: Passing a pointer-to-class-member as a template parameter
body: <p>I would like to write a function that apply a process to member of a class. The following code is working:</p>
  
  <pre><code>class AA
  {
  public:
      AA(){};
      ~AA(){};
      std::string type="AA";
  };
  
  class BB
  {
  public:
      BB(){};
      ~BB(){};
      template &lt;typename T, typename TT&gt;
      void test(T&amp; a, TT(T::*memberPtr))
      {
          std::cout&lt;&lt;"test: "&lt;&lt;(a.*memberPtr)&lt;&lt;std::endl;
      }
      std::string type="BB";
  };
  
  int main()
  {
      AA a;
      BB b;
      b.test(a, &amp;AA::type);
  }
  </code></pre>
  
  <p>But I know everything at compile-time so I am wondering if it is possible to write something equivalent but only with templates? So I could write something like:</p>
  
  <pre><code>b.test&lt;&amp;AA::type&gt;(a);
  </code></pre>
  
  <p>that calls inside test(a):</p>
  
  <pre><code>std::cout&lt;&lt;"test: "&lt;&lt; (a.*MEMBER) &lt;&lt;std::endl; // MEMBER is given in template
  </code></pre>
  
  <p>or something like that.</p>