The following code:
struct A
{
int f(int);
auto g(int x) -> decltype(f(x));
};
Fails to compile with the error:
error: cannot call member function 'int B::f(int)' without object
If I change it to:
struct A
{
int f(int);
auto g(int x) -> decltype(this->f(x));
};
I get another error:
error: invalid use of 'this' at top level
What is wrong with either of these? I am using gcc 4.6
Here are the magic words:
struct A
{
int f(int);
auto g(int x) -> decltype((((A*)0) ->* &A::f)(x)) ;
};
Edit I see from Mikael Persson's answer that this is how it's done in boost.