C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: pointers to functions and pointers to static member func

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Kurt Krueckeberg
Guest





PostPosted: Fri Jun 27, 2003 4:48 pm    Post subject: Re: pointers to functions and pointers to static member func Reply with quote




Quote:
Hello,
can I use pointers to functions and pointers to static member
functions (with same argument and return types) interchangebly?
I thing I've found ansswer in the C++ standard (in [5.2.2]), but I am
not sure that I interpret it correctly - I would prefer more direct
statement and I could not find one.

Thanks,
Michael Furman
static member function pointers are not the same type as class member

function pointers.

class Sample {

public:

static int StaticThatReturnsInt();

int MemberThatReturnsInt();

};

typedef int (*pIntFunc)();

typedef int (Sample::*pSampleIntFunc)();



//. . .

pIntFunc pf = &Sample::StaticThatReturnsInt;

pSampleIntFunc psf = &Sample::MemberThatReturnsInt;


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Michael Furman
Guest





PostPosted: Sat Jun 28, 2003 12:33 pm    Post subject: Re: pointers to functions and pointers to static member func Reply with quote




"Maciej Sobczak" <maciej (AT) maciejsobczak (DOT) com> wrote

Quote:
Hi,

Michael Furman wrote:
[...]
I thing I've found answer in the C++ standard (in [5.2.2]), but I am
not sure that I interpret it correctly - I would prefer more direct
statement and I could not find one.

"A static member function is an ordinary function." - this footnote, in
the context of postfix function call expression, is enough. It means
that if you have a pointer to function, you can use it to store
addresses of normal functions as well as static member functions.
[...]
That is exactly what I have found myself (footnote in [5.2.2]) I hoped

that there is more direct wording in the main text.
Thanks,
Michael Furman




[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Michael Furman
Guest





PostPosted: Sat Jun 28, 2003 12:36 pm    Post subject: Re: pointers to functions and pointers to static member func Reply with quote




"Daniel Spangenberg" <dsp (AT) bdal (DOT) de> wrote

Quote:
Hello Michael Furman!

Michael Furman schrieb:

Hello,
can I use pointers to functions and pointers to static member
functions (with same argument and return types) interchangebly?
I thing I've found ansswer in the C++ standard (in [5.2.2]), but I am
not sure that I interpret it correctly - I would prefer more direct
statement and I could not find one.

Thanks,
Michael Furman

Your statement is somewhat misleading. There does not exist a special
type of pointer to static member functions. But you can always take a
normal function pointer to a static member function, provided that you
don't need a function pointer with linkage specification different from
extern "C++" (See 7.5).

Can you explain what is misleading? (I guess I should add "and same
linkage").
I've found only one footnote in [5.2.2] and asking is there more direct
words
in the Standard.
Thanks,
Michael Furman




[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Daniel Spangenberg
Guest





PostPosted: Mon Jun 30, 2003 5:39 pm    Post subject: Re: pointers to functions and pointers to static member func Reply with quote

Hello, Michael!

Michael Furman schrieb:

Quote:
Your statement is somewhat misleading. There does not exist a
special
type of pointer to static member functions. But you can always take
a
normal function pointer to a static member function, provided that
you
don't need a function pointer with linkage specification different
from
extern "C++" (See 7.5).

Can you explain what is misleading? (I guess I should add "and same
linkage").
I've found only one footnote in [5.2.2] and asking is there more
direct
words
in the Standard.
Thanks,
Michael Furman

Sorry for the confusion. My **introductory** sentence was simply
bullsh...
and *it* was the one and only misleading thing. I hope you accept my
apology for this.
Fortunately, this did not have any influence on the remainder of my
posting....

I also think, that Our Holy Standard is somewhat stingy concerning its
explanations of static member functions. The linkage stuff is explained
loosely in 3.5/5 and 7.5, and 9.3 and 9.4 clarify not too much.
Some indirect conclusion can be drawn from 3.9.2:
"- pointers to void or objects or functions (including static members of
classes)
of a given type, 8.3.1;"
while 8.3.3 excludes pointer to static members of a class.

The most direct sentence I could find was in 13.4/3:
"Nonmember functions and static member functions match targets of type
"pointer-to-function"
or "reference-to-function.""

Greetings from Bremen,

Daniel





[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.