Note that there are some explanatory texts on larger screens.

plurals
  1. POBoost::bind a method with boost::function parameter
    primarykey
    data
    text
    <p>I would like to provide an extra boost::function to a async_write. I want the connections own HandleWrite function to be called first and then call the provided boost::function.</p> <p>Member method of Connection that binds to asio async_write</p> <blockquote> <pre><code>void Connection::HandleWrite( const boost::system::error_code&amp; e, boost::function&lt;void (const boost::system::error_code&amp;)&gt; handler) { // Code removed for clarity if(!handler.empty()) handler(e); }; </code></pre> </blockquote> <p>Trying to bind HandleWrite to a asio async_write and provide another bind as the value for handler. This doesn't compile. What am I doing wrong?</p> <blockquote> <pre><code> void Connection::QueueRequest( boost::shared_array&lt;char&gt; message, std::size_t size, boost::function&lt;void (const boost::system::error_code&amp;)&gt; handler) { // Code hidden for clarity boost::asio::async_write(m_Socket, boost::asio::buffer(buffer), boost::bind(&amp;Connection::HandleWrite, shared_from_this(), boost::asio::placeholders::error, handler ) ); } </code></pre> </blockquote> <p>The error message I get from the compiler is the following:</p> <blockquote> <pre><code>Error 1 error C2825: 'F': must be a class or namespace when followed by '::' boost\bind\bind.hpp 69 Error 2 error C2039: 'result_type' : is not a member of '`global namespace'' boost\bind\bind.hpp 69 Error 3 error C2146: syntax error : missing ';' before identifier 'type' boost\bind\bind.hpp 69 Error 4 error C2208: 'boost::_bi::type' : no members defined using this type boost\bind\bind.hpp 69 Error 5 fatal error C1903: unable to recover from previous error(s); stopping compilation boost\bind\bind.hpp 69 </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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