BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_memberfunctionpointertraits

Macros

#define bslmf_MemberFunctionPointerTraits   bslmf::MemberFunctionPointerTraits
 This alias is defined for backward compatibility.
 
#define bslmf_IsMemberFunctionPointer   bslmf::IsMemberFunctionPointer
 This alias is defined for backward compatibility.
 
#define bslmf_MemberFunctionPointerTraitsImp    bslmf::MemberFunctionPointerTraits_Imp
 This alias is defined for backward compatibility.
 

Detailed Description

Outline

Purpose

Provide meta-functions to detect member function pointer traits.

Classes

See also
bslmf_functionpointertraits

Description

This component provides meta-functions for determining the traits of a member function pointer. Two meta-functions are provided: bslmf::IsMemberFunctionPointer, and bslmf::MemberFunctionPointerTraits. bslmf::IsMemberFunctionPointer tests if a given type is a supported member function pointer. bslmf::MemberFunctionPointerTraits determines the traits of a member function type, including the type of the object that it is a member of, its result type, and the type of its list of arguments.

Note that, in order to support pre-C++11 compilers in a manageable way, only member functions with up to 14 arguments and no C-style (varargs) elipses are supported on all platforms by this component. When variadic templates are available, any number of arguments are supported. C-style elipses are not supported by this component at all. To identify all member function pointers see bslmf_ismemberfunctionpointer .

Usage

Define the following function types:

typedef void (*VoidFunc0)();

and the following struct with the following members:

struct MyTestClass {
static void voidFunc0() {}
int func1(int) { return 0; }
int func2(int, int) { return 1; }
};

In order to deduce the types of voidFunc0 and func1, we will use the C++ template system to get two auxiliary functions:

template <class t_TYPE>
void checkNotMemberFunctionPointer(t_TYPE object)
{
}
template <class t_BSLMF_RETURN, class t_ARGS, class t_TYPE>
void checkMemberFunctionPointer(t_TYPE object)
{
ResultType;
typedef typename
ArgumentList;
}
Definition bslmf_issame.h:146
Definition bslmf_memberfunctionpointertraits.h:164
Definition bslmf_memberfunctionpointertraits.h:150

The following program should compile and run without errors:

void usageExample()
{
checkNotMemberFunctionPointer(&MyTestClass::voidFunc0);
checkMemberFunctionPointer<int, bslmf::TypeList1<int> >(
&MyTestClass::func1);
checkMemberFunctionPointer<int, bslmf::TypeList2<int, int> >(
&MyTestClass::func2);
}

Macro Definition Documentation

◆ bslmf_IsMemberFunctionPointer

#define bslmf_IsMemberFunctionPointer   bslmf::IsMemberFunctionPointer

◆ bslmf_MemberFunctionPointerTraits

#define bslmf_MemberFunctionPointerTraits   bslmf::MemberFunctionPointerTraits

◆ bslmf_MemberFunctionPointerTraitsImp

#define bslmf_MemberFunctionPointerTraitsImp    bslmf::MemberFunctionPointerTraits_Imp