From 5134208583669932
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c997c315a835018d
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1993-10-15 11:13:34 PST
Path: gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!emx.cc.utexas.edu!not-for-mail
From: jamshid@emx.cc.utexas.edu (Jamshid Afshar)
Newsgroups: comp.std.c++
Subject: Re: Implicit conversions for pointer-to-member
Date: 15 Oct 1993 12:28:00 -0500
Organization: The University of Texas - Austin
Lines: 36
Message-ID: <29mmj0INN8rd@emx.cc.utexas.edu>
References: <CEwALG.6s6@ucc.su.OZ.AU> <60.1286.4352.0N186751@canrem.com>
NNTP-Posting-Host: emx.cc.utexas.edu
Summary: it's not allowed; don't know why

In article <60.1286.4352.0N186751@canrem.com>,
Gordan Palameta <gordan.palameta@canrem.com> wrote:
>OK, I think this has been misinterpreted. [...]
>    B Foo::*  <--  D Foo::*     // Foo:: and Foo::      B* and D*

Ohhh.  Yes, you have been misinterpreted.  You're asking whether a
pointer to member (not member function) of class Foo can convert to
another pointer to member of the same class Foo.

	class B {};
	class D : public B {};

	class Foo {
	public:
	   B base;
	   D derived;
	};

	B Foo::* bmp;   // pointer to a B member of Foo
	bmp = &Foo::base;     // okay
	bmp = (B Foo::*) &Foo::derived;   // okay
	bmp = &Foo::derived;  // ???

The conversion is definitely legal with a cast: ARM 5.4 "A pointer to
a member may be explicitly converted into a different pointer to
member type where the tw types are pointers to members of the same
class [...]".  It doesn't seem to be legal without the cast.  4.8 says
"Note that a pointer to member is not a pointer to object or a pointer
to function and the rules for conversions of such pointers DO NOT
APPLY to pointers to member.  In particular, a pointer to member
cannot be converted to a void*." [emphasis mine]

I'm not sure why the conversion is not allowed.  It seems type-safe.
Anyone?

Jamshid Afshar


