• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can anyone explain what the function argument declaration: ( int _Tp::* ) means ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone explain what the function argument declaration: ( int _Tp::* ) means ?


  • Subject: Re: Can anyone explain what the function argument declaration: ( int _Tp::* ) means ?
  • From: David A Rowland <email@hidden>
  • Date: Tue, 21 Nov 2006 14:58:13 -0800

At 8:35 PM +0000 11/21/06, Daniel Stenning wrote:
Can anyone explain what the function argument in:
 __one __test_type(int _Tp::*);

 means ?

Tp is a template place holder. It is in a function template. Here is the
full code:

namespace __gnu_internal
{
  typedef char __one;
  typedef char __two[2];

  template<typename _Tp>
  __one __test_type(int _Tp::*);
  template<typename _Tp>
  __two& __test_type(...);

} // namespace __gnu_internal





It is a pointer to an int data member of the class _Tp. The entire line is a function prototype, and the name of the parameter is not given. It would appear in the function definition. Here are some notes I use in a C++ class I teach:


Pointer to member is a bit surprising. It is not a pointer in the usual sense but a more complex structure containing the offset of a member within an object, not its absolute address. It can point to a member datum or function.

Pointer to member can be set to 0 and tested for equality to 0. No other value than 0 can be used. If you extract its value as an integer it will be 0 or perhaps 1, but not the offset you expect.

Assume this has been defined:

class Z{
	public: int a, b, w;
	void fz(int) {}
};

Z zz;


Pointer to an integer data member of class Z:

int Z::* pmd;

pmd = 0;
Correct. any pointer can be set to 0 (but no other constant)

if (pmd == 0)
Correct, any pointer can be tested against 0	(but  to no other constant)

pmd = &zz.w;
Error, &zz.w is int*, not the same as int Z::*

pmd = &Z::w;
Correct, but pmd is an abstract pointer. You cannot use it by itself.

zz.*pmd = 3;
Correct, this will set zz.w to 3.


David _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Can anyone explain what the function argument declaration: ( int _Tp::* ) means ? (From: Daniel Stenning <email@hidden>)

  • Prev by Date: XCode bugs
  • Next by Date: Re: Parallel builds on Intel Mac failing..... start loosing trust in MacOS X....
  • Previous by thread: Can anyone explain what the function argument declaration: ( int _Tp::* ) means ?
  • Next by thread: Re: why don't custom views have a "tag" in IB?
  • Index(es):
    • Date
    • Thread