8

C++ permits function pointers and function references. It also permits pointers-to-member-functions.

But does it permit references-to-member-functions?

I can't seem to deduce the rules from the standard, and I've failed to make a program work with them.


[ member function pointers ] [ member function references ]

Community
  • 1
  • 1
Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989
  • Apart from the intriguing aspect of it, Is there any practical application of this feature that you think this would be need? – Alok Save Dec 14 '11 at 16:48
  • @Als: If I wanted to use references rather than pointers. – Lightness Races in Orbit Dec 14 '11 at 16:51
  • 1
    I think it should be banned to answer your own questions. –  Dec 14 '11 at 17:16
  • @g24l: [Why's that?](http://meta.stackexchange.com/questions/12513/should-i-not-answer-my-own-questions) – Lightness Races in Orbit Dec 14 '11 at 17:19
  • 2
    @g24: From the FAQ: "There are already numerous posts that answer their own questions. There's nothing wrong with it. It's even encouraged." (http://meta.stackexchange.com/questions/17463) – Martin B Dec 14 '11 at 17:26
  • What's with the downvotes? This is a concise, specific question about a programming language. – Lightness Races in Orbit Dec 14 '11 at 17:52
  • 1
    @TomalakGeret'kal: You can see why (you have donwvotes) in your own link [just scroll down an answer](http://meta.stackexchange.com/a/12514/138817) – Martin York Dec 14 '11 at 18:08
  • I just don't like it and there is no rule for me to like or to upvote for those who do it. You should leave some time before you answer as a courtesy to fellow users. I downvoted because the question (in my opinion ) does not show any research effort. –  Dec 14 '11 at 18:40
  • @g24l: I don't see how waiting is courteous; that's what the technical limitation that I cannot _accept_ my own answer for 2 whole days is for -- you are welcome to continue posting whatever answer you like. As for your downvote reason... well, touché. My research effort went into the answer ;) _(Though I did indicate that I'd already perused the standard...)_ – Lightness Races in Orbit Dec 14 '11 at 18:46

1 Answers1

6

[C++11: 8.3.3/3]: A pointer to member shall not point to a static member of a class (9.4), a member with reference type, or “cv void.” [ Note: See also 5.3 and 5.5. The type “pointer to member” is distinct from the type “pointer”, that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer declarator syntax. There is no “reference-to-member” type in C++. —end note ]

Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989