Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Firstly, typedefs are your friend:</p> <pre><code>typedef std::function&lt;void(void)&gt; RequestFunc; typedef std::function&lt;void(const std::string&amp;, const std::string&amp;)&gt; DispatchFunc; </code></pre> <p>We can now present your declarations as follows. I have changed the parameter to <code>deliver</code> to take a dispatchFunc (as the original one was a void taking no parameters). I also added <code>;</code> after the class declarations and made the functions you are attempting to bind with <code>public</code>, because of accessibility issues:</p> <pre><code>class A { std::string name; std::string location; public: void deliver( const DispatchFunc&amp; request ) { request( name, location ); } }; class B { public: void dispatch( const DispatchFunc&amp; request ) { }; }; </code></pre> <p>Secondly, I suspect that your <code>deliver()</code> function actually requires a <code>DispatchFunc</code> typedef. Without knowing the purpose of your snippet, it is difficult to tell what you want types you want to bind to.</p> <p>Now that's sorted, on to the declarations. There are issues with using <code>bind</code> (in Windows, at least) due to naming conflicts with the windows socket library. This may or may not be an issue on your compiler, but it's always a good idea to prefix the <code>boost</code> namespace:</p> <pre><code> B b; auto func1 = boost::bind( &amp;B::dispatch, b ); A a; auto func2 = boost::bind( &amp;A::deliver, a, func1); </code></pre> <p>These modifications got a successful compile for me. As for the rest and what you <em>intend</em> to do, good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload