title: Error using std::bind and std::function in C++
body: <p>I attempt to try my snippet of Newton's method on a multivariate function and used <code>std::bind</code> and <code>std::function</code>. But I was stuck on an error</p>
  
  <blockquote>
    <p>error: conversion from 'std::_Bind_helper&amp;, int>::type {aka
    std::_Bind, int))(double, double,
    double)>}' to non-scalar type 'std::function'
    requested</p>
  </blockquote>
  
  <p>What does this error message mean and how should I fix my current code?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;functional&gt;
  #include&lt;cmath&gt;
  
  double newton(std::function&lt;double(double)&gt; F, std::function&lt;double(double)&gt; f,
                double x=0, int maxiter=1000, double epsilon=0.001)
  {
      int n = 0;
      while((n &lt; maxiter) &amp;&amp; (fabs(F(x)) &gt; epsilon))
      {
          x = x - F(x) / f(x);
          n++;
      }
      return x;
  }
  
  // I'd like to fix x and z at 1 and 2 and find root for y
  double ftest(double x, double y, double z) 
  {
      return x * x + (y * y - 2 * y - 4) + z * z;
  }
  
  // Partial derivative of ftest with regards to y
  double ftest1(double y) 
  {
      return 2 * y - 2;
  }
  
  int main()
  {
      using namespace std::placeholders;
      std::function&lt;double(double)&gt; F = std::bind(ftest, 1, _2, 2);
      std::function&lt;double(double)&gt; f = ftest1;
      std::cout &lt;&lt; newton(F, f);
      return 0;
  }
  </code></pre>