Swaminathan N. (swami++at++evl.uic.edu)
Wed, 14 May 1997 12:22:06 -0500 (CDT)
> >
> > I recive the warning:
> >
> > warning(3676): pointer-to-member-function cast to pointer
> > to function
> >
> > mv_body->setTravFuncs(PFTRAV_CULL,(pfNodeTravFuncType)walk,NULL);
> >
>
> I just had the same problem a couple of days ago, in that the C++
> compiler would not let me make a reference to a member function in
> anything other than an invocation. I assume this is disallowed to
> make dealing with virtual functions easier. At any rate, I set
> the traversal _data_ for the node to -this-, and used a callback
> to a passthrough function to actually call the member function.
>
> I would be interested to know why you can't do this as above...
>
Typically pointers to member functions have a larger size than pointers to
functions. This is because extra data has to be stored if the pointer to
member function is virtual. For instance, if you call such a member function
you get virtual dispatch. Note that there is no difference between pointer
to member function and pointer to virtual member function.
What you actually want is something called a bound pointer, &node.callback(),
which was consciously decided against in the standard. You could hack that
with templates. There's an article by Hicks in the C++ report (also reprinted
in C++ Gems) that deals with precisely this issue.
bye
Swami
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
v Swaminathan Narayanan ^
v swami++at++evl.uic.edu ^
v Office: 996-3002 ^
v Home: 850-2726 ^
v http://www.evl.uic.edu/swami ^
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:13 PDT