Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to declare a function type that uses itself as an argument in C++?

Tags:

c++

For instance, is there any legal equivalent to this?

typedef void (*SelfReferencingFnPtr)(int, SelfReferencingFnPtr);

With clang, this causes the error "unknown name SelfReferencingFnPtr".

The best I was able to come up with is a functor whose operator() accepts its own type.

like image 839
zneak Avatar asked Apr 11 '15 23:04

zneak


1 Answers

No, see GotW #57. It's indeed a recursive problem.

like image 104
MSalters Avatar answered Oct 05 '22 17:10

MSalters