typedef bool (*Foo)(Foo a, Foo b);
How do you declare a function pointer that accepts itself in its parameters?
Indirectly:
struct Foo{
typedef bool (*FooPtr)(Foo a, Foo b);
Foo(FooPtr p)
: p(p)
{}
bool operator()(Foo a, Foo b) const{
return p(a,b);
}
FooPtr p;
};
struct Bar{
Bar(Foo f)
: some_callback(f)
{}
Foo some_callback;
};
bool a_callback(Foo a, Foo b){
return false;
}
int main() {
Bar b(a_callback);
b.some_callback(Foo(a_callback), Foo(a_callback));
}
Not that I could ever see any use in that, as you can see from my example.