P
P
Pinkman2021-11-29 03:08:25
ASIO
Pinkman, 2021-11-29 03:08:25

What is transferred with bind?

Had seen. here is the code:

_acceptor.async_accept(_socket,
      boost::bind(&Acceptor::handleAccept,
      this,
      boost::asio::placeholders::error));

void	Server::Acceptor::handleAccept(const boost::system::error_code &e)

The question arose, what is being bound here? Why is this being passed ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2021-11-29
@gbg

Acceptor::handleAccept is a non-static method of the Acceptor class.
For static methods, the first parameter must be a pointer to an instance of the class. When you call class methods directly, the compiler does this substitution implicitly. When you do this through bind, you need to pass such a pointer yourself, in this case, this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question