title: Boost function and boost bind: Bind the return value?
body: <p>This is related to this previous question: <a href="https://stackoverflow.com/questions/7893768/using-boostbind-with-boostfunction-retrieve-binded-variable-type">Using boost::bind with boost::function: retrieve binded variable type</a>.</p>
  <p>I can bind a function like this:</p>
  <p>in .h:</p>
  <pre><code>class MyClass
  {
      void foo(int a);
      void bar();
      void execute(char* param);
      int _myint;
  }
  </code></pre>
  <p>in .cpp</p>
  <pre><code>MyClass::bar()
  {
      vector&lt;boost::function&lt;void(void)&gt; myVector;
      myVector.push_back(boost::bind(&amp;MyClass::foo, this, MyClass::_myint);
  }
  MyClass::execute(char* param)
  {
      boost::function&lt;void(void)&gt; f  = myVector[0];
      _myint = atoi(param);
      f();
  }
  </code></pre>
  <p>But how can I bind a return value ? i.e.:</p>
  <p>in .h:</p>
  <pre><code>class MyClass
  {
      double foo(int a);
      void bar();
      void execute(char* param);
      int _myint;
      double _mydouble;
  }
  </code></pre>
  <p>in .cpp</p>
  <pre><code>MyClass::bar()
  {
      vector&lt;boost::function&lt;void(void)&gt; myVector;
      //PROBLEM IS HERE: HOW DO I BIND &quot;_mydouble&quot;
      myVector.push_back(boost::bind&lt;double&gt;(&amp;MyClass::foo, this, MyClass::_myint);
  }
  MyClass::execute(char* param)
  {
      double returnval;
      boost::function&lt;void(void)&gt; f  = myVector[0];
      _myint = atoi(param);
      //THIS DOES NOT WORK: cannot convert 'void' to 'double'
      // returnval = f();
      //MAYBE THIS WOULD IF I COULD BIND...:
      // returnval = _mydouble;
  
  }
  </code></pre>