|
发表于 2004-8-18 18:06:00
|
显示全部楼层
Re:[C++][指针]关于指向成员函数的指针~
template <typename OT, typename PFT>
struct _wkMFPointer
{
};
template <typename OT,typename RT>
struct _wkMFPointer< OT, RT(*)() >
{
typedef RT (OT::*type)();
};
template <typename OT, typename RT, typename AT>
struct _wkMFPointer< OT, RT(*)(AT) >
{
typedef RT (OT::*type)(AT);
};
template <typename OT, typename RT, typename AT1, typename AT2>
struct _wkMFPointer< OT, RT(*)(AT1,AT2) >
{
typedef RT (OT::*type)(AT1,AT2);
};
template <typename OT, typename RT, typename AT1, typename AT2, typename AT3>
struct _wkMFPointer< OT, RT(*)(AT1,AT2,AT3) >
{
typedef RT (OT::*type)(AT1,AT2,AT3);
};
// 用于const函数
template <typename OT, typename PFT>
struct _wkCMFPointer
{
};
template <typename OT, typename RT>
struct _wkCMFPointer< OT, RT(*)() >
{
typedef RT (OT::*type)() const;
};
template <typename OT, typename RT, typename AT>
struct _wkCMFPointer< OT, RT(*)(AT) >
{
typedef RT (OT::*type)(AT) const;
};
template <typename OT, typename RT, typename AT1, typename AT2>
struct _wkCMFPointer< OT, RT(*)(AT1,AT2) >
{
typedef RT (OT::*type)(AT1,AT2) const;
};
template <typename OT, typename RT, typename AT1, typename AT2, typename AT3>
struct _wkCMFPointer< OT, RT(*)(AT1,AT2,AT3) >
{
typedef RT (OT::*type)(AT1,AT2,AT3) const;
};
呵呵,用模板偏特化,2003才能编译通过。 |
|