title: use std::bind with overloaded functions
body: <p>I cannot find out how to bind a parameter to an overloaded function using <code>std::bind</code>. Somehow <code>std::bind</code> cannot deduce the overloaded type (for its template parameters). If I do not overload the function everything works. Code below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  using namespace std::placeholders;
  
  double f(double x) 
  {
      return x;
  }
  
  // std::bind works if this overloaded is commented out
  float f(float x) 
  {
      return x;
  }
  
  // want to bind to `f(2)`, for the double(double) version
  
  int main()
  {
  
      // none of the lines below compile:
  
      // auto f_binder = std::bind(f, static_cast&lt;double&gt;(2));
  
      // auto f_binder = bind((std::function&lt;double(double)&gt;)f, \
      //  static_cast&lt;double&gt;(2));
  
      // auto f_binder = bind&lt;std::function&lt;double(double)&gt;&gt;(f, \
      //  static_cast&lt;double&gt;(2));
  
      // auto f_binder = bind&lt;std::function&lt;double(double)&gt;&gt;\
      // ((std::function&lt;double(double)&gt;)f,\
      //  static_cast&lt;double&gt;(2));
  
      // cout &lt;&lt; f_binder() &lt;&lt; endl; // should output 2
  }
  </code></pre>
  
  <p>My understanding is that <code>std::bind</code> cannot deduce somehow its template parameters, since <code>f</code> is overloaded, but I cannot figure out how to specify them. I tried 4 possible ways in the code (commented lines), none works. How can I specify the type of function for <code>std::bind</code>? Any help is much appreciated! </p>