🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2885

Re: What is the actual type of a pointer-to-member?

#2885
From: John Max Skaller
Date: Wed, 06 Dec 1995 18:45
51 lines
1915 bytes
Peter Hubel <ludvig@daimi.aau.dk> wrote:
>
>I have a question regarding pointers-to-members.
>Given these two classes:
>
>  struct B {
>    int b;
>  }
>
>  struct D : public B {
>    int d;
>  };
>
>Will the type of the expression '&D::b' be 'int D::*' or 'int B::*'?

   int B::*

 -- which I personally regard as a SERIOUS blunder.

>What I'd like is that '&D::b' is of type 'int D::*' whereas '&B::b' is of 
>type 'int B::*'. 

I agree completely. But it is not the case. You must write:

  (int D::*)&B::b //or
  static_cast<int D::*>(&B::b)

Even worse, the pointer to member system is functionally
incomplete: there's no way to add two pointers to members.
Hence it is impossible to navigate a membership tree.

I have some templates called TypedOffset<Class, Member>
which provide a complete algebra suitable for implementing
meta-classes -- but I can't support inheritance conversions
(at least not without member templates); nor functions.
[alpha testers and designers welcome, please email me]

-- 
John Max Skaller               voice: 61-2-566-2189
81 Glebe Point Rd              fax:   61-2-660-0850
GLEBE NSW 2037                 email: maxtal@suphys.physics.oz.au
AUSTRALIA                      email: skaller@maxtal.com.au




---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4a4fmu$sp8@oznet03.ozemail.com.au>
Path: arc1-ca.pugleaf.net!news.duke.edu!agate!agate!Matt
References: <01BABB82.F5809FE0@default>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.duke.edu!agate!agate!Matt
From: John Max Skaller <maxtal@suphys.physics.su.oz.au>
Newsgroups: comp.std.c++
Subject: Re: What is the actual type of a pointer-to-member?
Date: 06 Dec 1995 18:45:55 GMT
Organization: MAXTAL
Approved: Matt@Austern
Message-ID: <4a4fmu$sp8@oznet03.ozemail.com.au>
References: <01BABB82.F5809FE0@default>
NNTP-Posting-Host: austern.hip.berkeley.edu