Boost logo

Boost Users :

Subject: Re: [Boost-users] Member-Function to String conversion.
From: Andrea Denzler (andrea_at_[hidden])
Date: 2008-11-03 10:09:11


If you want to use that pointer, i.e. call the member function, then you
must define it in some way (and you must retrieve the member object too).
How you define the function?

pointer_type pointer;
pointer = someobject.get_pointer( "foobar2" );

What is pointer_type? Once you define pointer_type you can use it in the
bimap.

A pointer to a member function is still a simple function pointer, this is
why you need the member pointer to call it. A member function is nothing
more than a normal function with the special *this* pointer assigned to the
member object that called the function (and of course the code inside the
function use implicitly the this pointers when accessing any member item).
With virtual functions the function pointer is not static but stored in the
class.

Andrea

> -----Messaggio originale-----
> Da: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] Per conto di Siegfried Kettlitz
> Inviato: lunedì 3 novembre 2008 15.48
> A: boost-users_at_[hidden]
> Oggetto: Re: [Boost-users] Member-Function to String conversion.
>
> > You need two maps (string->pointer and pointer->string), a bimap should
> do
> > the work. Isn't it possible to cast a function pointer to a generic void
> *
> > pointer as the base class for the bimap?
>
> Sorry, this doesn't work. A "pointer to a member function" is _not_ a
> "function pointer" and not a general (void*) pointer. It's size is
> bigger than a pointer to a normal function because it stores
> additional information about the object. I haven't found a conversion
> between all "pointer to member functions" to something "comparable"
> like a normal pointer or a number or a string. (Maybe typeinfo helps?
> Is it portable?)
>
> Take a look at this for the strange objects that member function pointers
> are:
> > http://www.codeproject.com/KB/cpp/FastDelegate.aspx
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net