FX::Generic::FnInfo< fn > Struct Template Reference
[Generic Tools in TnFOX]

#include <FXGenericTools.h>

List of all members.


Detailed Description

template<typename fn>
struct FX::Generic::FnInfo< fn >

Extracts type information from a function pointer type.

Use as follows:

class Test
{
    int *foo(double);
};
// Need to convert the function pointer into a function pointer type
// using template argument deduction
template<typename fn> void GetFnInfo(fn funcPtr)
{
    typedef FX::Generic::FnInfo<fn> fooInfo;
    typedef fooInfo::resultType result;     // result becomes "int *"
    typedef fooInfo::objectType object;     // object becomes "class Test"
    typedef fooInfo::par1Type par1;         // par1 becomes "double"
}
...
GetFnInfo(&Test::foo);
Up to four parameters are supported. You can also read isConst which becomes true when the function pointer type refers to a const function and arity for how many parameters there are. objectType becomes NullType when the function pointer is not a member function of a class. asList is a typelist with the first item the result type and subsequent items the parameters.

If the function pointer type is not a pointer to code, arity becomes -1 and resultType becomes the type passed as template parameter.

Public Types

typedef fn resultType
typedef NullType objectType
typedef TL::create< resultType >
::value 
asList

Static Public Attributes

static const bool isConst
static const int arity


The documentation for this struct was generated from the following file:

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:30:07 2008 for TnFOX by doxygen v1.5.6