Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bslmf_memberpointertraits
[Package bslmf]

Provide meta-function to detect pointer to member traits. More...

Namespaces

namespace  bslmf

Detailed Description

Outline
Purpose:
Provide meta-function to detect pointer to member traits.
Classes:
bslmf::MemberPointerTraits meta-function to get member pointer traits
See also:
Component bslmf_memberfunctionpointertraits
Description:
This component provides a meta-function, bslmf::MemberPointerTraits, that determines traits of a pointer-to-member type, including the type of the object that it is a member of, and the type of the member it addresses.
Usage:
Define the following struct with the following members:
  struct MyTestClass {
      int func1(int) { return 0; }
      int d_int;
  };
In order to deduce the types of func1 and d_int, we will use bslmf::MemberPointerTraits.
  template <class MEMBER, class CLASS, class t_TYPE>
  void checkMemberPointer(t_TYPE pointer)
  {
      (void) pointer;
      typedef typename bslmf::MemberPointerTraits<t_TYPE>::MemberType
          MemberType;
      typedef typename bslmf::MemberPointerTraits<t_TYPE>::ClassType
          ClassType;
      assert(1 == (bsl::is_same<MemberType, MEMBER>::value));
      assert(1 == (bsl::is_same<ClassType, CLASS>::value));
  }
The following program should compile and run without errors:
  void usageExample()
  {
      checkMemberPointer<int(int), MyTestClass>(&MyTestClass::func1);
      checkMemberPointer<int, MyTestClass>(&MyTestClass::d_int);
  }