Topic: subscripting and overloading.
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Sun, 28 Nov 1993 23:58:17 GMT Raw View
In article <27185@alice.att.com> ark@alice.UUCP () writes:
>In article <CGwzAF.IvA@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>
>> From article <1993Nov22.150153.25902@vedge.com>, by hendrik@vedge.com (Hendrik Boom):
>> > Section 5.2.1 says
>> > The expression E1[A2] is identical (by definition) to *((E1)+(E2)).
>> > Does this hold even if * and + have been overloaded?
>
>> Obviously not. What if operator+ returns void? (Sick, but
>> possible.)
>
>Well ... that question doesn't quite reveal the whole story.
>
>E1[E2] is defined as *((E1)+(E2)) only if E1 and E2 are, or are converted
>to, built-in types....
That sounds like a very sensible rule.
It's just a pity that 5.2.1 doesn't state it.
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Wed, 1 Dec 1993 03:51:08 GMT Raw View
rfg@netcom.com (Ronald F. Guilmette) writes:
>ark@alice.UUCP () writes:
>>E1[E2] is defined as *((E1)+(E2)) only if E1 and E2 are, or are converted
>>to, built-in types....
>
>That sounds like a very sensible rule.
>
>It's just a pity that 5.2.1 doesn't state it.
It's stated at the start of section 5:
"Relations between operators ... are NOT GUARANTEED FOR OVERLOADED
OPERATORS" [my emphasis]
"This section defines the operators WHEN APPLIED TO TYPES FOR
WHICH THEY HAVE NOT BEEN OVERLOADED." [my emphasis]
--
Fergus Henderson fjh@munta.cs.mu.OZ.AU
Author: hendrik@vedge.com (Hendrik Boom)
Date: Mon, 22 Nov 1993 15:01:53 GMT Raw View
Section 5.2.1 says
The expression E1[A2] is identical (by definition) to *((E1)+(E2)).
Does this hold even if * and + have been overloaded?
I won't even ask whether it holds if [] has been overloaded.
hendrik.
--
-------------------------------------------------------
Try one or more of the following addresses to reply.
at work: hendrik@vedge.com, iros1!vedge!hendrik
at home: uunet!ozrout!topoi!hendrik
Author: b91926@fnclub.fnal.gov (David Sachs)
Date: 22 Nov 1993 19:45:26 GMT Raw View
In article <1993Nov22.150153.25902@vedge.com>, hendrik@vedge.com (Hendrik Boom) writes:
|> Section 5.2.1 says
|> The expression E1[A2] is identical (by definition) to *((E1)+(E2)).
|> Does this hold even if * and + have been overloaded?
|> I won't even ask whether it holds if [] has been overloaded.
This definition of subscripting holds only for the case in which buolt-in subscripting is defined: One of the items must be a pointer and the other must be of an integer type. In such cases overloading is impossible, as overloading requires that an operand be of a user-defined type.
Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Mon, 22 Nov 1993 22:18:10 GMT Raw View
Author: ark@alice.att.com (Andrew Koenig)
Date: 23 Nov 93 13:55:21 GMT Raw View
In article <CGwzAF.IvA@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
> From article <1993Nov22.150153.25902@vedge.com>, by hendrik@vedge.com (Hendrik Boom):
> > Section 5.2.1 says
> > The expression E1[A2] is identical (by definition) to *((E1)+(E2)).
> > Does this hold even if * and + have been overloaded?
> Obviously not. What if operator+ returns void? (Sick, but
> possible.)
Well ... that question doesn't quite reveal the whole story.
E1[E2] is defined as *((E1)+(E2)) only if E1 and E2 are, or are converted
to, built-in types. In that case, let C1 be the result of converting E1
and C2 be the result of converting E2. In that case, one of C1 and C2
must be an integer and the other must be a pointer and E1[E2] is
really defined as identical to *((C1)+(C2)). Because of the types of
C1 and C2, the * and the + must be the built-in operators; overloading
cannot apply.
--
--Andrew Koenig
ark@research.att.com