std::bind overload resolution
Posted
by
bpw1621
on Stack Overflow
See other posts from Stack Overflow
or by bpw1621
Published on 2010-11-11T21:33:13Z
Indexed on
2012/09/29
3:37 UTC
Read the original article
Hit count: 142
The following code works fine
#include <functional>
using namespace std;
using namespace std::placeholders;
class A
{
int operator()( int i, int j ) { return i - j; }
};
A a;
auto aBind = bind( &A::operator(), ref(a), _2, _1 );
This does not
#include <functional>
using namespace std;
using namespace std::placeholders;
class A
{
int operator()( int i, int j ) { return i - j; }
int operator()( int i ) { return -i; }
};
A a;
auto aBind = bind( &A::operator(), ref(a), _2, _1 );
I have tried playing around with the syntax to try and explicitly resolve which function I want in the code that does not work without luck so far. How do I write the bind line in order to choose the call that takes the two integer arguments?
© Stack Overflow or respective owner