title: Question about function pointers, map and templates
body: <p>I'm learning about function pointers and maps. I have to use function pointers and maps to write a replication of switch-statements without using if or switch.</p>
  
  <p>I want to write a function execute() that take two arguments "a" and "b" and do an operation with the appropriate operation character. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;map&gt;
  using namespace std;
  
  
  // define the function pointer fptr, templated
  template &lt;typename T&gt;
  using fptr = T(*)(T, T);
  
  template &lt;typename T&gt;
  T plus(T a, T b){
      return a + b;
  }
  
  template &lt;typename T&gt;
  T minus(T a, T b){
      return a - b;
  }
  
  template &lt;typename T&gt;
  T multiply(T a, T b){
      return a * b;
  }
  
  template &lt;typename T&gt;
  T divide(T a, T b){
     return a / b
  }
  
  // Call back the function pointer on two variables
  template &lt;typename T&gt;
  T operation(fptr&lt;T&gt; f, T a, T b){
      f(a, b);
  }
  
  // Execute map to fit an operation character to an operation function pointer
  
  template &lt;typename T&gt;
  T execute(T a, T b, char c){
      std::map&lt;char, fptr&lt;T&gt; &gt; m;
      m['+'] = &amp;plus;
      m['-'] = &amp;minus;
      m['*'] = &amp;multiply;
      m['/'] = &amp;divide;
  
      return operation(m[c], a, b);
  }
  
  int main(){
      execute&lt;int&gt;(1, 2, '+');
      execute&lt;double&gt;(1.2, 3.4, '/');
  }
  </code></pre>
  
  <p>These below are the errors that I got. I got no typos in the call back, but the errors still say ambiguous. I wonder why that happen. I really appreciate the suggestions. Thanks a lot!</p>
  
  <pre><code>error: reference to 'plus' is ambiguous
      m['+'] = &amp;plus;
                ^
  note: candidate found by name lookup is 'plus'
  T plus(T a, T b){
    ^
  note: candidate found by name lookup is 'std::__1::plus'
  struct _LIBCPP_TEMPLATE_VIS plus : binary_function&lt;_Tp, _Tp, _Tp&gt;
                          ^
  error: reference to 'minus' is ambiguous
      m['-'] = &amp;minus;
            ^
  note: candidate found by name lookup is 'minus'
  T minus(T a, T b){
    ^
  note: candidate found by name lookup is 'std::__1::minus'
  struct _LIBCPP_TEMPLATE_VIS minus : binary_function&lt;_Tp, _Tp, _Tp&gt;
                          ^
  </code></pre>