1

Topic: The pointer on kvajn-function

Greetings, Last night in a head the bad idea climbed through: and whether it is possible ++ to write on a C typedef, the setting pointer on function? Certainly, it is possible, the brain answered. And whether it is possible, that this function accepted in parameter other same function (or even a little), the bad idea was not appeased. And that returned result too the pointer on the same function. Well, you remember, how in a joke about auto auto (auto)? In general, here. Whether It is possible to describe somehow similar kvajn-function? In a forehead - it is impossible, the compiler does not understand function parameter type because did not compile still itself  on function. Sample magic? typedef int (*foo) (char);//OK typedef bar (*bar) (bar);//Tell  is not present! typedef bar (*bar) (bar, bar); P.S. Practical sense here any - simply fluctuation of neural activity. P.P.S. Any substance did not suffer.

2

Re: The pointer on kvajn-function

Hello, Mr. Delphist, you wrote: whether MD> It is possible to describe somehow similar kvajn-function? In a forehead - it is impossible, the compiler does not understand function parameter type because did not compile still itself  on function. Sample magic?  such it is impossible, since forward declaration for synonyms of types it is inadmissible (though it is possible to create a synonym for forward declared a class). I.e. something similar can be carried out only for functors (lambdas or classes with operator ()).

3

Re: The pointer on kvajn-function

Hello, Mr. Delphist, you wrote: MD> in general, here. Whether It is possible to describe somehow similar kvajn-function? In a forehead - it is impossible, the compiler does not understand function parameter type because did not compile still itself  on function. Sample magic? Yes it is simple to you of a stack does not suffice. Increase indefinitely and all.

4

Re: The pointer on kvajn-function

Mr. Delphist: MD> in general, here. Whether It is possible to describe somehow similar kvajn-function? In a forehead - it is impossible, the compiler does not understand function parameter type because did not compile still itself  on function. Sample magic? Skilled   such question comes: whether function can return the pointer on itself. Is among Gerba Sattera tasks in one of its books. For With ++ 03 task directly did not dare. It was necessary or return (void *) or to invent a class. I think since then cardinal changes it is not necessary to wait - the task not so practical (though Satter suggested to use this bicycle in implementation of finite state machines).

5

Re: The pointer on kvajn-function

Hello, Drobodan Frilich, you wrote: > Skilled   such question comes: whether function can return the pointer on itself. > is among Gerba Sattera tasks in one of its books. ... Means, I skilled ? More likely, the skilled fan-pljusovik

6

Re: The pointer on kvajn-function

Hello, Mr. Delphist, you wrote: MD> in general, here. Whether It is possible to describe somehow similar kvajn-function? In a forehead - it is impossible, the compiler does not understand function parameter type because did not compile still itself  on function. Sample magic? Almost after all: * At barclass it is possible to cause brackets as though it is the pointer on function; * Implicit conversion there-back; * At last, it is possible to assume that at enough optimizing compiler the class barclass will be you-is optimized. struct barclass; typedef barclass (*bar) (barclass); struct barclass {barclass (): b (0) {} template <class T> barclass (T t): b (t) {} operator bar () const {return b;} bar b;}; int main () {barclass b = [] (barclass b) {return b;}; **** b; b = b (b); return 0;}

7

Re: The pointer on kvajn-function

Mr. Delphist: >> Skilled   such question comes: whether function can return the pointer on itself. >> is among Gerba Sattera tasks in one of its books. MD> Hmmm... Means, I skilled ? More likely, the skilled fan-pljusovik And besides not skilled fan-logician