Topic: what this means ?


Author: rmartin@rcmcon.com (Robert Martin)
Date: Fri, 27 Jan 1995 17:35:19 GMT
Raw View
wwpaxg@urc.tue.nl (Xie Gaohong) writes:

>template <class T>
> void(T::*v_Sig(void(T::*pmf)())) ()
>  {
>  return pmf;
>  }


>It seems to me that the function call has nothing to do with function
>arguments, but returned a a member of function pointer from function
>names, can any one explain it to me more clearly. Or I need to update
>some latest C++ features.

Well, this is a beaut.

v_Sig is a template function which takes an argument which is a member
function of T that takes nothing and returns nothing.  'pmf' is
correctly declared as the name of the argument of v_Sig.   v_Sig
returns a pointer to a member function of T which takes nothing and
returns nothing.   (whew).  The function simply returns its argument.

Okay, lets take this apart.  Start with the name of the function.

 v_Sig

It is a function.  Parens bind tighter than * so:

 v_Sig()

Now v_Sig returns a void(T::*)(), that is, a pointer to a member
function of T that takes nothing and returns nothing.  So:

        void(T::*   v_Sig()   )()

The argument of v_Sig is named pmf, and it is also a void(T::*)().
So:

        void(T::*v_Sig(  void(T::*pmf)()  ))()

It takes a truly great language to support such incredible
obfuscation.

--
Robert Martin       | Design Consulting   | Training courses offered:
Object Mentor Assoc.| rmartin@rcmcon.com  |   Object Oriented Analysis
2080 Cranbrook Rd.  | Tel: (708) 918-1004 |   Object Oriented Design
Green Oaks IL 60048 | Fax: (708) 918-1023 |   C++




Author: wwpaxg@urc.tue.nl (Xie Gaohong)
Date: 24 Jan 95 13:50:29 GMT
Raw View
Hi, C++ gurus:

I have some problem in understanding the following:

template <class T>
LRESULT(T::*LRESULT_WPARAM_LPARAM_Sig(LRESULT(T::*pmf)(WPARAM, LPARAM)))
   (WPARAM, LPARAM)
 {
 return pmf;
 }

Or
template <class T>
 void(T::*v_Sig(void(T::*pmf)())) ()
  {
  return pmf;
  }


It seems to me that the function call has nothing to do with function arguments,
but returned a a member of function pointer from function names, can any one
explain it to me more clearly. Or I need to update some latest C++ features.

Many Thanks

e-mail to : wwpaxg@urc.tue.nl

Gaohong Xie