title: Pointer to member function in template class
body: <p>I want to eliminate the process consumed by a decision using pointers to member functions. I need to give user options to turn on or off domain checking for a function defined on a limited continues domain.</p>
  
  <p>It's ok to have pointers to member functions when not using templates. But here I have to generalize my implementation.</p>
  
  <p>Specifically I have three member functions in my class:</p>
  
  <p>1.<code>value</code> is a member function returns value calculated by the member that <code>function</code> points to. The <code>function</code> is a function pointer wich points to either <code>checkedValue</code> or <code>uncheckedValue</code>.
  2.<code>checkedValue</code> is a member function that calculates and returns the result, if input is in specified range. else throws a std::domain error.
  3.<code>uncheckedValue</code> calculates and returns the result, regardless of domain.</p>
  
  <pre><code>template &lt;typename T&gt;
  class IO
  {
  private:
      typedef T (IO&lt;T&gt;::*functionPtr)(const std::string&amp; name, const T&amp; input) const;
      functionPtr function;
      bool domainValidation;
      void setDomainValidation(const bool&amp; value);
      //...
  public:
      // ...
      T value(const std::string&amp; name, const T&amp; input) const;
      T uncheckedValue(const std::string&amp; name, const T&amp; input) const;
      T checkedValue(const size_t&amp; index, const T &amp;input) const;
  };
  
  // Implementation:
  
  template &lt;typename T&gt;
  void IO&lt;T&gt;::setDomainValidation(const bool &amp;value)
  {
      domainValidation = value;
      if(domainValidation)
      {
          // function points to checkedValue()
          function =  &amp; IO&lt;T&gt;::checkedValue; // Here I got undefinded reference error
      }
      else
      {
          // function points to uncheckedValue()
      }
  }
  
  template &lt;typename T&gt;
  T IO&lt;T&gt;::value(const string &amp;name, const T &amp;input) const
  {
      return (this-&gt;*function)(name,input);
  }
  
  template &lt;typename T&gt;
  T IO&lt;T&gt;::uncheckedValue(const string &amp;name, const T &amp;input) const
  {
      // simply calculate and return the result
  }
  
  template &lt;typename T&gt;
  T IO&lt;T&gt;::checkedValue(const string &amp;name, const T &amp;input) const
  {
      // if input is in domain, calculate and return the result
      // else throw a std::domain error
  }
  </code></pre>