title: How to use boost::bind to create a function wrapper
body: <p>I want to use boost::bind (I'm not sure if it is really the right solution to my problem) to create a wrapper to a function that takes one or two arguments, while the wrapper takes only one argument and fixes the other to some constant value. My functions look like</p>
  
  <pre><code>double f(double a, double b)
  {
    return a/b;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>double g(double b)
  {
    return 2*b; // b+b?
  }
  </code></pre>
  
  <p>In my code I have a typedef for a function with one argument:</p>
  
  <pre><code>typedef boost::function&lt;double (double)&gt; callback;
  </code></pre>
  
  <p>and my idea was to create the function wrapper with this:</p>
  
  <pre><code>callback cb;
  cb = boost::bind(f, _1, 2)(x);
  </code></pre>
  
  <p>so that I could call a third function that <em>uses</em> a wrapped function passed in the arguments:</p>
  
  <pre><code>double use(callback cb, double x, double y)
  {
    return cb(x0) - y0;
  }
  </code></pre>
  
  <p>I have about 30 functions with one or two arguments, and the first or the second must be a constant. This constant is not known to <code>use()</code>, but the algorithm implemented in <code>use</code> works with every function.</p>
  
  <p>When I try to compile my code, I get an error for the line <code>cb = boost::bind(f, _1, 2)(x);</code>:</p>
  
  <pre><code>'* f' cannot be used as a function
  </code></pre>
  
  <p>When I try to use the bind directly, as in <code>cout &lt;&lt; boost::bind(f, _1, 2)(x);</code>, I don't get an error.</p>
  
  <p>What have I done wrong here?</p>