Topic: Overloading operator& (was Recursive templates)


Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Thu, 30 Sep 1993 06:46:29 GMT
Raw View
In article <28clvpINN42o@borg.cs.unc.edu> leech@cs.unc.edu (Jon Leech) writes:
>In article <rfgCE4MMp.9B4@netcom.com>, rfg@netcom.com (Ronald F. Guilmette) writes:
>
>    Does the emerging standard say anything about uses like:
>
> T obj[1];
> T *pobj = obj; // Does not call T::operator& (using g++ or cfront)

I happen to believe that you have asked a very astute question.  (Others
may disagree.)

I believe that if there is any justice in this world, and if the type T
has a user-defined operator& defined for it, then that operator really
ought to be invoked for the second line of your example.  (I certainly
cannot see how a case could be made for NOT invoking the user's operator&
in such a circumstance.)

P.S.  Earlier, I bemoaned that fact that some identities which exist in
ANSI C are NOT identities in C++.  I think your example code illustrates
yet another such case.  In C, we always knew that whenever an expression
`E' having some array type appeared in any context (other than as an
operand of unary `&' or sizeof) if the expression was itself an lvalue,
then E was equivalent in every respect to `&E[0]'.  I find it unfortunate
that in C++, this identity seems also to have been lost (at least if one
accepts the judgments of the particular implementations you experimented
on).

Follow-ups to comp.std.c++ please.

--

-- Ronald F. Guilmette ------------------------------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------