Self-referential function pointers

While trying to come up with an elegant way of emulating TCO in C++, I came up with this odd construct:
typedef T (*foo)(T2, foo &);
But the compiler rejects it (presumably on moral grounds). Isn't there any way to get it to submit?

EDIT: Let's try to avoid subverting the type system, if at all possible.

EDIT 2: This works:
1
2
3
4
5
6
7
struct TCO;

typedef T (*foo)(T2, TCO &);

struct TCO{
    foo f;
};
Last edited on
Topic archived. No new replies allowed.