user10956: I need to pass a class member function to server.on, unfortunately i get an error.

error: no matching function for call to 'ESP8266WebServer::on

I have done some searching but could not understand anything I found. No simple explanation.
This works:
void handleRoot(){}
server.on("/", handleRoot);

This doesn't:
void myClass::handleRoot(){}
void myClass::setup(){
    server.on("/", handleRoot);
}

The second argument to server.on is 
typedef std::function<void(void)> THandlerFunction;

Unfortunately I have no idea what it means.

user7856: It's quite common question related to C++ programming.
The extensive explanation can be found here.
The short answer is: it's very different from taking the address of a regular function.
Workarounds (that might or might not work for you, depending on what else you need that function to do) are:

make it static
declare it as friend function, rather than member function

Either way, the point is that it should not be something associated to an instance of the class, but rather to the class as a whole.

user53194: This will get the job done - using anonymous function syntax:
server->on("/", [&]() {
   handleRoot();
});


user13755: I've ben hitting this same problem.
Some further research on c++ syntax helped me find this clean solution, based on the  
std::bind syntax:
server.on("/", std::bind(&myClass::handleRoot, this));


10956: <p>I need to pass a class member function to server.on, unfortunately i get an error.</p>

<blockquote>
  <p>error: no matching function for call to 'ESP8266WebServer::on</p>
</blockquote>

<p>I have done some searching but could not understand anything I found. No simple explanation.</p>

<p>This works:</p>

<pre><code>void handleRoot(){}
server.on("/", handleRoot);
</code></pre>

<p>This doesn't:</p>

<pre><code>void myClass::handleRoot(){}
void myClass::setup(){
    server.on("/", handleRoot);
}
</code></pre>

<p>The second argument to server.on is </p>

<pre><code>typedef std::function&lt;void(void)&gt; THandlerFunction;
</code></pre>

<p>Unfortunately I have no idea what it means.</p>
 7856: <p>It's quite common question related to C++ programming.</p>

<p>The extensive explanation can be found <a href="http://www.parashift.com/c++-faq/pointers-to-members.html" rel="nofollow">here</a>.</p>

<p>The short answer is: it's very different from taking the address of a regular function.</p>

<p>Workarounds (that might or might not work for you, depending on what else you need that function to do) are:</p>

<ul>
<li>make it static</li>
<li>declare it as friend function, rather than member function</li>
</ul>

<p>Either way, the point is that it should not be something associated to an instance of the class, but rather to the class as a whole.</p>
 53194: <p>This will get the job done - using anonymous function syntax:</p>

<pre><code>server-&gt;on("/", [&amp;]() {
   handleRoot();
});
</code></pre>
 13755: <p>I've ben hitting this same problem.<br>
Some further research on c++ syntax helped me find this clean solution, based on the  </p>

<p>std::bind syntax:</p>

<pre><code>server.on("/", std::bind(&amp;myClass::handleRoot, this));
</code></pre>
