The following code:
struct A
{
int f(int);
auto g(int x) -> decltype(f(x));
};
Fails to compile with the error:
erro
After some tests, neither decltype(declval().f(x))
nor decltype(((A*)0)->f(x))
will work.
However, it seems that using boost::bind will work (and it's "under-the-hood" version):
struct A
{
int f(int);
auto g(int x) -> decltype(boost::bind(&A::f,0,x)());
auto h(int x) -> decltype((((A*)0)->*(&A::f))(x)); //similarly (what Boost.Bind does under-the-hood.
};
Of course, this is not pretty. I guess you can look into how boost::bind does it to maybe find a nicer solution.
EDIT
As MSN suggested, you can also make your own function template to resolve this:
template< typename R, typename C, typename... Args > R member_func(R (C::*)(Args...));
struct A
{
int f(int);
auto g(int x) -> decltype(member_func(&A::f));
};