Using std::function to call a member function while using templates
<p>I have a templated class like this:</p>

<pre><code>template &lt;typename T&gt;
class AguiEvent {


std::vector&lt;std::tr1::function&lt;void(T, AguiWidget*)&gt;&gt; events;
public:
void call(AguiWidget* sender, T arg) const;
void addHandler(std::tr1::function&lt;void(T, AguiWidget*)&gt; proc);
void removeHandler(std::tr1::function&lt;void(T, AguiWidget*)&gt; proc);
void removeHandler();
AguiEvent();
};

template &lt;typename T&gt;
void AguiEvent&lt;T&gt;::removeHandler()
{
    if(events.size() &gt; 0)
    {
        events.pop_back();
    }
}


template &lt;typename T&gt;
void AguiEvent&lt;T&gt;::addHandler( std::tr1::function&lt;void(T, AguiWidget*)&gt; proc)
{
    events.push_back(proc);
}


template &lt;typename T&gt;
void AguiEvent&lt;T&gt;::removeHandler(std::tr1::function&lt;void(T, AguiWidget*)&gt; proc)
{
    for(int i = 0; i &lt; events.size(); ++i)
    {
        if(events[i] == proc)
        {
            events.erase(events.begin() + i);
            return;
        }
    }
}


template &lt;typename T&gt;
void AguiEvent&lt;T&gt;::call(AguiWidget* sender, T arg) const
{
    for(size_t i = 0; i &lt; events.size(); ++i)
        events[i](arg,sender);
}

template &lt;typename T&gt;
AguiEvent&lt;T&gt;::AguiEvent()
{
}
</code></pre>

<p>However using it like this:</p>

<pre><code>testWidget[count]-&gt;eventMouseClick.addHandler(&amp;testWidget[0]-&gt;silly);
</code></pre>

<p>causes this error:</p>

<pre><code>Error   5   error C2276: '&amp;' : illegal operation on bound member function expression    c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\main.cpp   190
</code></pre>

<p>I thought std::function allowed this. What am I doing wrong?</p>

<p>Thanks</p>
