RE: [Boost-users] Re: a question on boost::is_function

boost::is_function
::value
I know it's confusing. Most C++ programmers never see a function type in the wild. You can use remove_pointer to turn a pointer-to-function into a function.
Could I do ... int (int) * p_my_function_pointer; Or some other such madness? I'm reading MSDN about the indirection operator at the moment, maybe that will help to clear this up in my head. Can you recommend a page on "function types". Gaz -- Dave Abrahams Boost Consulting http://www.boost-consulting.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Foster, Gareth wrote:
boost::is_function
::value I know it's confusing. Most C++ programmers never see a function type in the wild. You can use remove_pointer to turn a pointer-to-function into a function.
Could I do ...
int (int) * p_my_function_pointer;
Or some other such madness?
Yes, some other. The "*" and variable name goes in between the return type and the parameter list if you're declaring a function pointer: int (*p_my_function_pointer) (int)
I'm reading MSDN about the indirection operator at the moment, maybe that will help to clear this up in my head. Can you recommend a page on "function types".
'fraid not. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

Foster, Gareth wrote:
boost::is_function
::value I know it's confusing. Most C++ programmers never see a function type in the wild. You can use remove_pointer to turn a pointer-to-function into a function.
Could I do ...
int (int) * p_my_function_pointer;
No, but you can do typedef int my_function( int ); and now do my_function * my_function_pointer; You can even do struct X { my_function f; }; but don't ask me why you'd want or need to do that.

Could I do ...
int (int) * p_my_function_pointer;
Or some other such madness? I'm reading MSDN about the indirection operator at the moment, maybe that will help to clear this up in my head. Can you recommend a page on "function types".
You can certainly do it via a typedef: typedef int mysig(int); mysig* p_my_function; // declares function pointer mysig myproc; // declares a function called myproc with signature mysig. John.
participants (4)
-
David Abrahams
-
Foster, Gareth
-
John Maddock
-
Peter Dimov